必须在含 scrapy.cfg 的 Scrapy 项目目录下启动,否则报错;项目依赖需自行装齐;只适合单次请求快速返回的爬虫,不适合长时间运行的爬取
pip install scrapyrt
cd my/project_path/is/quotesbot
scrapyrtREADME 未说明
给 Scrapy 项目加 HTTP API,按 spider 名和 URL 实时取回抓取结果
把 Scrapy 爬虫包装成 HTTP API,让其他语言或服务能远程触发爬虫并实时拿到抓取结果,省去自己搭调度和传输层。
核心能力
- 在 Scrapy 项目目录启动 HTTP 服务,按 spider 名和 URL 调度爬虫
- 以 JSON 返回 spider 采集到的 items
- 支持 Scrapy 全部组件,如中间件、pipeline、扩展
- 请求可指定 callback 和 crawl_args 传参
容易踩的坑
- 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_requestsAPI parameter is deprecated in favor of a newspider_startAPI parameter.Same with the corresponding
__init__parameter and attribute of theCrawlManagerclass.
-
- v0.16.02024-02-14 · 2024-02-14 09:19 UTC
查看更新说明
What's Changed
- Handling errbacks by @pawelmhm in https://github.com/scrapinghub/scrapyrt/pull/158
- Make the errback handling method configurable by @radostyle in https://github.com/scrapinghub/scrapyrt/pull/156
New Contributors
- @radostyle made their first contribution in https://github.com/scrapinghub/scrapyrt/pull/156
Full Changelog: https://github.com/scrapinghub/scrapyrt/compare/v0.15.0...v0.16.0
- v0.15.02023-09-20 · 2023-09-20 07:25 UTC
查看更新说明
- fix compatibility with Scrapy 2.11 on crawler object
- v0.14.02023-08-10 · 2023-08-10 09:18 UTC
查看更新说明
- fix compatibility with scrapy 2.10 https://github.com/scrapinghub/scrapyrt/pull/150
- drop end of life pythons (3.6, 3.7)
- add python 3.11 support
- v0.13v0.13.02021-12-10 · 2021-12-10 10:53 UTC
查看更新说明
- add support for specifying Twisted reactor in Scrapy settings or ScrapyRT settings, fixes https://github.com/scrapinghub/scrapyrt/issues/132
- drop Python 3.5 support
- add Python 3.10 support
- remove distutils call https://github.com/scrapinghub/scrapyrt/commit/4e4c6f5ab2306580401e05d295f1ed6f0f46a3e6
- README updates
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
.. 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/>_ orScrapy 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>_.