scrapyrt

scrapinghubBSD-3-Clause活跃维护

把 Scrapy 爬虫包装成 HTTP API,让其他语言或服务能远程触发爬虫并实时拿到抓取结果,省去自己搭调度和传输层。

HTTP API for Scrapy spiders

v0.17.0发布于 2025-07-28 17:15 UTC885star161fork同步于 2026-11-10 23:53 UTC

怎么上手

由 README 提炼,执行前请确认
pip install scrapyrt
cd my/project_path/is/quotesbot
scrapyrt
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

给 Scrapy 项目加 HTTP API,按 spider 名和 URL 实时取回抓取结果

把 Scrapy 爬虫包装成 HTTP API,让其他语言或服务能远程触发爬虫并实时拿到抓取结果,省去自己搭调度和传输层。

核心能力

  • 在 Scrapy 项目目录启动 HTTP 服务,按 spider 名和 URL 调度爬虫
  • 以 JSON 返回 spider 采集到的 items
  • 支持 Scrapy 全部组件,如中间件、pipeline、扩展
  • 请求可指定 callback 和 crawl_args 传参

容易踩的坑

必须在含 scrapy.cfg 的 Scrapy 项目目录下启动,否则报错;项目依赖需自行装齐;只适合单次请求快速返回的爬虫,不适合长时间运行的爬取

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.17.0
  1. v0.17.0最新正式版2025-07-28 · 2025-07-28 17:15 UTC
    • Added support for Scrapy 2.13+.

    • Lowered the minimum required Scrapy version from 2.10 to 2.7.

    • The start_requests API parameter is deprecated in favor of a new spider_start API parameter.

      Same with the corresponding __init__ parameter and attribute of the CrawlManager class.

  2. v0.16.02024-02-14 · 2024-02-14 09:19 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/scrapinghub/scrapyrt/compare/v0.15.0...v0.16.0

  3. v0.15.02023-09-20 · 2023-09-20 07:25 UTC
    查看更新说明
    • fix compatibility with Scrapy 2.11 on crawler object
  4. v0.14.02023-08-10 · 2023-08-10 09:18 UTC
    查看更新说明
  5. v0.13v0.13.02021-12-10 · 2021-12-10 10:53 UTC
    查看更新说明

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    .. image:: https://raw.githubusercontent.com/scrapinghub/scrapyrt/master/artwork/logo.gif :width: 400px :align: center

    ========================== ScrapyRT (Scrapy realtime)

    .. image:: https://github.com/scrapinghub/scrapyrt/workflows/CI/badge.svg :target: https://github.com/scrapinghub/scrapyrt/actions

    .. image:: https://img.shields.io/pypi/pyversions/scrapyrt.svg :target: https://pypi.python.org/pypi/scrapyrt

    .. image:: https://img.shields.io/pypi/v/scrapyrt.svg :target: https://pypi.python.org/pypi/scrapyrt

    .. image:: https://img.shields.io/pypi/l/scrapyrt.svg :target: https://pypi.python.org/pypi/scrapyrt

    .. image:: https://img.shields.io/pypi/dm/scrapyrt.svg :target: https://pypistats.org/packages/scrapyrt :alt: Downloads count

    .. image:: https://readthedocs.org/projects/scrapyrt/badge/?version=latest :target: https://scrapyrt.readthedocs.io/en/latest/api.html

    Add HTTP API for your Scrapy <https://scrapy.org/>_ project in minutes.

    You send a request to ScrapyRT with spider name and URL, and in response, you get items collected by a spider visiting this URL.

    • All Scrapy project components (e.g. middleware, pipelines, extensions) are supported
    • You run Scrapyrt in Scrapy project directory. It starts HTTP server allowing you to schedule spiders and get spider output in JSON.

    Quickstart

    1. install

    .. code-block:: shell

    > pip install scrapyrt
    

    2. switch to Scrapy project (e.g. quotesbot project)

    .. code-block:: shell

    > cd my/project_path/is/quotesbot
    

    3. launch ScrapyRT

    .. code-block:: shell

    > scrapyrt
    

    4. run your spiders

    .. code-block:: shell

    > curl "localhost:9080/crawl.json?spider_name=toscrape-css&url=http://quotes.toscrape.com/"
    

    5. run more complex query, e.g. specify callback for Scrapy request and zipcode argument for spider

    .. code-block:: shell

    >  curl --data '{"request": {"url": "http://quotes.toscrape.com/page/2/", "callback":"some_callback"}, "spider_name": "toscrape-css", "crawl_args": {"zipcode":"14000"}}' http://localhost:9080/crawl.json -v
    

    Scrapyrt will look for scrapy.cfg file to determine your project settings, and will raise error if it won't find one. Note that you need to have all your project requirements installed.

    Note

    • Project is not a replacement for Scrapyd <https://scrapyd.readthedocs.io/en/stable/>_ or Scrapy Cloud <https://www.zyte.com/scrapy-cloud/>_ or other infrastructure to run long running crawls
    • Not suitable for long running spiders, good for spiders that will fetch one response from some website and return items quickly

    Documentation

    Documentation is available on readthedocs <http://scrapyrt.readthedocs.org/en/latest/index.html>_.

    Support

    Open source support is provided here in Github. Please create a question issue_ (ie. issue with "question" label).

    Commercial support is also available by Zyte_.

    .. _create a question issue: https://github.com/scrapinghub/scrapyrt/issues/new?labels=question .. _Zyte: http://zyte.com

    License

    ScrapyRT is offered under BSD 3-Clause license <https://en.wikipedia.org/wiki/BSD_licenses#3-clause_license_(%22BSD_License_2.0%22,_%22Revised_BSD_License%22,_%22New_BSD_License%22,_or_%22Modified_BSD_License%22)>_.

    Development

    Development taking place on Github <https://github.com/scrapinghub/scrapyrt>_.