我正在使用 Scrapy 抓取一些页面。我从 excel 表中获取 start_urls,我需要将 url 保存在项目中。
class abc_Spider(BaseSpider):
name = 'abc'
allowed_domains = ['abc.com']
wb = xlrd.open_workbook(path + '/somefile.xlsx')
wb.sheet_names()
sh = wb.sheet_by_name(u'Sheet1')
first_column = sh.col_values(15)
start_urls = first_column
handle_httpstatus_list = [404]
def parse(self, response):
item = abcspiderItem()
item['url'] = response.url
问题是该网址被重定向到其他网址(因此在响应网址中提供了其他内容)。如何获取我从 excel 中获得的原始 url?