【发布时间】:2018-06-15 20:37:37
【问题描述】:
你好我是scrapy的新手,我需要在网上加载2个日期。如何将变量放入项目中?
fecha_today = datetime.date.today().strftime("%d-%m-%y")
fecha_yesterday = (datetime.date.today()- timedelta(1)).strftime("%d-%m-%y")
这是我的蜘蛛
def parse_date(self, response):
self.log("\n\n\n ponemos las fechas \n\n\n")
hxs = HtmlXPathSelector(response)
link_fecha = hxs.select('/html/body/table/tbody/tr[3]/td/a')
date_item= ItemLoader ( FechaItem ())
date_item.add_path('fecha_today','/html/body/table[1]/tbody/tr[2]/td/form/table/tbody/tr[3]/td[1]/span/input')
date_item.add_path('fecha_yesterday','/html/body/table[1]/tbody/tr[2]/td/form/table/tbody/tr[4]/td[1]/span/input')
return date_item.load_item()
我必须在 item.py 中放入什么才能让变量带走我? 项目.py
class FechaLoader(scrapy.loader.ItemLoader):
我需要把这些变量放到一个表中去
【问题讨论】:
标签: python variables scrapy load