No project description provided
Project description
fastapi_crawler_scheduler
使用
from fastapi_crawler_scheduler import TaskScheduler
from fastapi import FastAPI
import uuid
app = FastAPI()
task_scheduler = TaskScheduler(
app=app,
ssl=True,
project_name="project_name",
uuid_number=uuid.uuid4().__str__(),
redis_username='redis_username',
redis_password='redis_password',
redis_host="redis_host",
redis_port=6379,
)
def add_spider(**crawler_info):
pass
print(f"add_spider = {crawler_info}")
print("add_spider")
crawler_info = {
"topic": "website_washingtonpost",
"name": "华盛顿邮报",
"base_url": "https://www.washingtonpost.com/arcio/news-sitemap/",
"news_node_tag": "url",
"title_tag": "news:title",
"url_tag": "loc",
"need_translation": 1,
"special_language_code": None,
"language_tag": "news:language",
"title_handler_name": "remove_cdata"
}
# 新增任务
task_scheduler.insert_task(func=add_spider, interval=4, job_id="job_1", crawler_info=crawler_info)
# 更新任务
task_scheduler.update_task(func=add_spider, interval=4, job_id="job_1", crawler_info=crawler_info)
# 删除任务
task_scheduler.delete_task(job_id="job_1")
参数介绍
insert_task
# func:Callable 定时任务函数
# interval: int 任务间隔
# job_id: str 任务id
# crawler_info: Dict = None 任务参数
# trigger: str = "interval" 任务类型
update_task
# func:Callable 定时任务函数
# interval: int 任务间隔
# job_id: str 任务id
# crawler_info: Dict = None 任务参数
# trigger: str = "interval" 任务类型
delete_task
# job_id: str 任务id
安装
Pypi
$ pip install fastapi-crawler-scheduler
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for fastapi-crawler-scheduler-2.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c7c5c7b3774edf64e2b98255b09b5aec956676a89dec43f3c930a44fd1732ec |
|
MD5 | 207cbf21f131e40a79988a9b1c8e4be9 |
|
BLAKE2b-256 | e64f6c753f6e7655dcccac5ac8e42d5fd5f1ddba496166920fc6537aa1dca395 |
Close
Hashes for fastapi_crawler_scheduler-2.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e749ba51495fa024b271c7f229c223be245bfc397cfa3094e1b528b957672293 |
|
MD5 | b9b9453fa1f98016a800d121a50cac86 |
|
BLAKE2b-256 | 40f016797ca7cf35d7a7a1f1b31ba0a2c719efaa9844be0767c394098a14ecde |