我想抓取优惠券网站的优惠券,但是当我 试图运行爬虫它显示error.Please帮助。 谢谢。scrapy爬虫在爬行时显示错误
import scrapy
from scrapy.http import Request
from scrapy.selector import HtmlXPathSelector
from scrapy.spider import BaseSpider
class CuponationSpider(scrapy.spider):
name = "cupo"
allowed_domains = ["cuponation.in"]
start_urls = ["https://www.cuponation.in/firstcry-coupon#voucher"]
def parse(self, response):
all_items = []
divs_action = response.xpath('//div[@class="action"]')
for div_action in divs_action:
item = VoucherItem()
span0 = div_action.xpath('./span[@data-voucher-id]')[0]
item['voucher_id'] = span0.xpath('./@data-voucher-
id').extract()[0]
item['code'] = span0.xpath('./span[@class="code-
field"]/text()').extract()[0]
all_items.append(item)
>**Output** ERROR
File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open
raise URLError(err)URLError: <urlopen error timed out>
2017-07-25 16:36:59 [boto] ERROR: Unable to read instance data, giving
up
回答你的问题是在警告。不要使用scrapy.selector.HtmlXPathSelector使用scrapy.Selector – Neil
@Neil仍然没有解决的问题我也试过。 – abhi09sep
那现在的警告是什么?什么是错误? – Neil