我正在研究一个scrapy项目,从一个需要认证的网站下载图像.一切正常,我可以下载图像.我需要的是暂停和恢复蜘蛛以在需要时抓取图像.所以我使用了scrapy手册中提到的任何内容,如下所示.运行蜘蛛时使用了下面提到的查询
scrapy crawl somespider -s JOBDIR=crawls/somespider-1
Run Code Online (Sandbox Code Playgroud)
按CTRL + C中止发动机.要恢复使用相同的命令.
但是在恢复蜘蛛在几分钟内关闭后,它不会从它停止的地方恢复.
更新:
class SampleSpider(Spider):
name = "sample project"
allowed_domains = ["xyz.com"]
start_urls = (
'http://abcyz.com/',
)
def parse(self, response):
return FormRequest.from_response(response,
formname='Loginform',
formdata={'username': 'Name',
'password': '****'},
callback=self.after_login)
def after_login(self, response):
# check login succeed before going on
if "authentication error" in str(response.body).lower():
print "I am error"
return
else:
start_urls = ['..','..']
for url in start_urls:
yield Request(url=urls,callback=self.parse_phots,dont_filter=True)
def parse_photos(self,response):
**downloading image here**
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
这是我在暂停后运行蜘蛛时得到的日志
2014-05-13 15:40:31+0530 [scrapy] INFO: Scrapy 0.22.0 …Run Code Online (Sandbox Code Playgroud)