Comments (3)
一般这种情况是由单独的脚本写数据到队列中。
如果是使用rabbitmq作为队列,我自己写爬虫的时候是这么加的。
from scrapy.http.request import Request
from scrapy_distributed.queues.common import BytesDump, keys_string
from scrapy_distributed.queues.amqp import RabbitQueue
if __name__ == "__main__":
_queue: RabbitQueue = RabbitQueue.from_queue_conf("amqp://guest:guest@localhost:5672/?heartbeat=0", YourSpider.queue_conf)
body = json.dumps(keys_string(RabbitQueue._request_to_dict(Request(url=your_url), YourSpider())), cls=BytesDump)
_queue.channel.basic_publish(exchange="", routing_key=_queue.name, body=body, properties=BasicProperties(delivery_mode=2))
后续可以考虑封装起来。
from scrapy-distributed.
这样的话,1、start_requests方法 是不是就没有用了,或者说起始的url 为空, 任务会自动从队列中加载这样的逻辑?
我得想法2、是在sitemap.py 中模仿scrapy_redis实现一个类似RabbitMixin的方法,和scrapy_redis那样的逻辑就行了,您看这样可以吗?
from scrapy-distributed.
这样的话,1、start_requests方法 是不是就没有用了,或者说起始的url 为空, 任务会自动从队列中加载这样的逻辑?
我得想法2、是在sitemap.py 中模仿scrapy_redis实现一个类似RabbitMixin的方法,和scrapy_redis那样的逻辑就行了,您看这样可以吗?
用 start_requests 也是可以的。
如果是用sitemap爬虫,初始URL是从 sitemap_urls 取,和 scrapy 自带的 sitemap 爬虫一样。
from scrapy-distributed.
Related Issues (13)
- Implementation proposal HOT 2
- dynamic web crawlers HOT 1
- Support Delayed Message in RabbitMQ Scheduler
- Custom Interface for DupeFilter
- RocketMQ Scheduler
- RocketMQ Item Pipeline
- Support Scrapy 2.6+ HOT 1
- Redis Streams Scheduler
- Redis Streams Item Pipeline
- First feedback from users HOT 1
- SQLAlchemy Pipeline
- Congratulate HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scrapy-distributed.