Zha*_*hou 1 python urllib urllib2 web-crawler scrapy
这是scrapy文档中的一个例子:
$ curl http://localhost:6800/schedule.json -d project=myproject -d spider=somespider -d setting=DOWNLOAD_DELAY=2 -d arg1=val1
Run Code Online (Sandbox Code Playgroud)
但是如果我想同时设置DOWNLOAD_DELAY = 2和CONCURRENT_REQUESTS = 4,怎么办?以及如何使用 urllib2 做到这一点?
有两种解决方案。
第一个,试试这个:
$ curl http://localhost:6800/schedule.json -d project=myproject -d spider=somespider -d setting=DOWNLOAD_DELAY=2 -d setting=CONCURRENT_REQUESTS=4 -d arg1=val1
Run Code Online (Sandbox Code Playgroud)
第二个:新建一个settings.py在myproject文件夹中命名的文件(带有pipelines.py和的目录items.py)。并将所有设置放入其中。这是一个例子。