semvec/pypi-packages huggingface dataset:
easy-datetime 0.1.0
A simple package to automatically detect and convert datetime strings to Unix timestamps
License: MIT
Requires Python: >=3.6

# Easy DateTime

A simple Python package to automatically detect and convert datetime strings to Unix timestamps.
处理日期字符串真的是蛋疼。让我们一劳永逸地解决这个问题。

## Installation

```bash
pip install easy_datetime
```

## Usage

```python
from easy_datetime import to_unix

# Different format examples
unix_time = to_unix("2021-01-01 00:00:00")        # 1609459200
unix_time = to_unix("2021/01/01 00:00:00")        # 1609459200
```

## Features

- Automatic datetime string format detection
- Supports various date formats (YYYY-MM-DD, DD-MM-YYYY, MM/DD/YYYY, etc.)
- Returns Unix timestamp (seconds since epoch)
- Simple and easy to use

## Requirements

- Python >= 3.6
- python-dateutil >= 2.8.2

## License

MIT License
scrapy-rabbitmq-task 1.0.4
Rabbitmq for Distributed scraping
License: MIT


*** 1.0.4 版本新增功能** *

版本新增配置任务队列优先级,以用来支持有优先级的消息队列

```
#在settings.py 新增系列配置即可
'QUEUE_X_MAX_PRIORITY': 10
```



## Scrapy分布式RabbitMQ调度器

## 安装

使用pip安装

```
pip install scrapy-rabbitmq-task
```
或者克隆这个项目并且执行setup.py安装
```
python setup.py install
```

## 使用
### 第一步: 在你的项目中的settings.py中添加配置项
```
# 指定项目的调度器
SCHEDULER = "scrapy_rabbitmq_scheduler.scheduler.SaaS"

# 指定rabbitmq的连接DSN
RABBITMQ_CONNECTION_PARAMETERS = 'amqp://guest:guest@localhost:5672/'

# 指定重试的http状态码(重新加回队列重试)
SCHEDULER_REQUEUE_ON_STATUS = [500]

# 指定下载器中间件, 确认任务是否成功
DOWNLOADER_MIDDLEWARES = {
    'scrapy_rabbitmq_scheduler.middleware.RabbitMQMiddleware': 999
}
# 指定item处理方式, item会加入到rabbitmq中
ITEM_PIPELINES = {
    'scrapy_rabbitmq_scheduler.pipelines.RabbitmqPipeline': 300,
}
```

### 第二步: 修改Spider的继承类
```
import scrapy
from scrapy_rabbitmq_scheduler.spiders import RabbitSpider

class CustomSpider(RabbitSpider):
    name = 'custom_spider'    
    queue_name = 'test_urls' # 指定任务队列的名称
    items_key = 'test_item' # 指定item队列名称

    def parse(self, response):
        item = ... # parse item
        yield item
```

### 第三步: 将任务写入到RabbitMQ队列
```
#!/usr/bin/env python
import pika
import settings

connection = pika.BlockingConnection(pika.URLParameters(settings.RABBITMQ_CONNECTION_PARAMETERS))
channel = connection.channel()

queue_key = 'test_urls'

# 读取文件中的链接并写入到队列中
with open('urls.txt') as f:
    for url in f:
        url = url.strip(' \n\r')
        channel.basic_publish(exchange='',
                        routing_key=queue_key,
                        body=url,
                        properties=pika.BasicProperties(
                            content_type='text/plain',
                            delivery_mode=2
                        ))

connection.close()
```
urls.txt
```text
http://www.baidu.com
```