我正在尝试使用 scrapy 抓取此站点,但返回单个单元格中的所有值,除了不同行中的每个值。example:milage: 25milage: 377milage: 247433milage: 464130但我得到这样的数据example:milage:[u'25', u'377', u'247433', u'399109', u'464130', u'399631', u'435238', u'285000', u'287470', u'280000']这是我的代码import scrapyfrom ..items import ExampleItemfrom scrapy.selector import HtmlXPathSelectorurl = 'https://example.com'class Example(scrapy.Spider): name = 'example' allowed_domains = ['www.example.com'] start_urls = [url] def parse(self, response): hxs = HtmlXPathSelector(response) item_selector = hxs.select('//div[@class="listing_format card5 relative"]') for fields in item_selector: item = ExampleItem() item ['Mileage'] = fields.select('//li[strong="Mileage"]/span/text()').extract() yield item
添加回答
举报
0/150
提交
取消