上传文件至 'dagongPro/spiders'
新增:将新闻的发布者与发布时间分离,使用不同的item项保存到mysql中。
This commit is contained in:
parent
7230145007
commit
576dc30851
|
@ -54,12 +54,13 @@ class DagongSpider(scrapy.Spider):
|
|||
content = response.xpath('//div[@class="wrap_left"]/div[3]//text()').extract()
|
||||
content = ''.join(content)
|
||||
print(content)
|
||||
date = response.xpath('//div[@class="wrap_left"]/div[1]/div[1]//text()').extract()
|
||||
date = ''.join(date)
|
||||
date = response.xpath('//div[@class="wrap_left"]/div[1]/div[1]/span[1]/text()').extract_first()
|
||||
author = response.xpath('//div[@class="wrap_left"]/div[1]/div[1]/span[2]/text()').extract_first()
|
||||
|
||||
item = response.meta['item']
|
||||
item['content'] = content
|
||||
item['date'] = date
|
||||
item['author'] = author
|
||||
|
||||
yield item
|
||||
|
||||
|
|
Loading…
Reference in New Issue