在Scrapy中返回项目后如何继续爬行?
在收到响应后的spider中,我想下载并显示验证码图像,然后继续爬网:在Scrapy中返回项目后如何继续爬行?,scrapy,Scrapy,在收到响应后的spider中,我想下载并显示验证码图像,然后继续爬网: def get_captcha(self, response): print '\nLoading captcha...\n' item = CaptchaItem() hxs = HtmlXPathSelector(response) captcha_img_src = hxs.select('//*[@id="captcha-image"]/@src
def get_captcha(self, response):
print '\nLoading captcha...\n'
item = CaptchaItem()
hxs = HtmlXPathSelector(response)
captcha_img_src = hxs.select('//*[@id="captcha-image"]/@src').extract()[0]
item['image_urls'] = [captcha_img_src]
return item
但我不知道图像何时加载,以及在加载后如何继续爬行
仅供参考:没有cookie,无法下载验证码图像
提前谢谢 使用收益率而不是收益率:
def get_captcha(self, response):
print '\nLoading captcha...\n'
item = CaptchaItem()
hxs = HtmlXPathSelector(response)
captcha_img_src = hxs.select('//*[@id="captcha-image"]/@src').extract()[0]
item['image_urls'] = [captcha_img_src]
yield item
#you may display here your scraped item and after that
#your further post request goes here...
yield your_request
你想做什么??这个代码没有给你带来所有的验证码?请详细说明?我想显示下载的验证码,然后用scrapy发送post请求