Skip to main content

fastapi_crawler_scheduler


使用


from fastapi import FastAPI
from fastapi_crawler_scheduler import TaskScheduler

app = FastAPI()

task_scheduler = TaskScheduler(
    app=app,
    ssl=False,
    project_name="project_name",
    server_name="server_name",
    redis_username='redis_username',
    redis_password='redis_password',
    redis_host="127.0.0.1",
    redis_port=6379,
    thread_pool_size=50,
)

添加|更新任务 - add_task

interval类型

def add_spider(**crawler_info):
    print(f"add_spider = {crawler_info}")
    print("add_spider")


trigger = 'interval'
crawler_info = {
    "topic": "interval insert_task",
    "title_handler_name": "interval insert_task",
    "seconds": 4,
}
job_id = 'job_1'
task_scheduler.add_task(
    func=add_spider,
    job_id=job_id,
    trigger=trigger,
    crawler_info=crawler_info,
    seconds=4
)

date类型

def add_spider(**crawler_info):
    print(f"add_spider = {crawler_info}")
    print("add_spider")


trigger = 'date'
crawler_info = {
    "topic": "date insert_task",
    "title_handler_name": "date insert_task",
    "run_date": "2022-10-03 11:30:00",
}
job_id = 'job_1'
run_date = '2022-10-03 11:30:00'
task_scheduler.add_task(
    func=add_spider,
    job_id=job_id,
    trigger=trigger,
    crawler_info=crawler_info,
    run_date=run_date,
)

cron类型

def add_spider(**crawler_info):
    print(f"add_spider = {crawler_info}")
    print("add_spider")


job_id = 'job_1'
trigger = 'cron'
minute = '*/2'
crawler_info = {
    "topic": "cron update_task",
    "title_handler_name": "cron update_task",
    "minute": minute,
}
task_scheduler.add_task(
    func=add_spider,
    job_id=job_id,
    trigger=trigger,
    crawler_info=crawler_info,
    minute=minute,
)

删除任务 - delete_task

job_id = 'job_1'
task_scheduler.delete_task(job_id=job_id)

安装

Pypi

$ pip install fastapi-crawler-scheduler

Metadata

Release files for fastapi-crawler-scheduler 2.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-crawler-scheduler 2.1.5
File Size Uploaded Provenance Actions
fastapi_crawler_scheduler-2.1.5.tar.gz 7.6 kB Without provenance Details for fastapi_crawler_scheduler-2.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-crawler-scheduler 2.1.5
File Interpreter ABI Platform Actions
fastapi_crawler_scheduler-2.1.5-py3-none-any.whl Python 3 none any Details for fastapi_crawler_scheduler-2.1.5-py3-none-any.whl

Total release size: 16.9 kB

Release files / fastapi_crawler_scheduler-2.1.5.tar.gz

Download URL fastapi_crawler_scheduler-2.1.5.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bb672d1865bb85e6bdbc854fcb01b5210c70170832a8649928e8b3b372a1d6d3
BLAKE2b-256 checksum
How to use checksums
f1b342d2d1ffefe366664853194d7ba4ab18e5cd0fb2b697cf05e1698d72c69e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.5

Release files / fastapi_crawler_scheduler-2.1.5-py3-none-any.whl

Download URL fastapi_crawler_scheduler-2.1.5-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57a8dd5467a974363044f3dc645d77b10df5b517196b268f6d746cc0b3f46f8a
BLAKE2b-256 checksum
How to use checksums
7235a7b59e3c104b17780f9ea82fad93d2265b8370beee2967891dfaa740df84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.5

Security for fastapi-crawler-scheduler 2.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.1.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page