我想解析Google搜索,并从搜索结果中的每个项目获取RSS链接。 我用Scrapy。 我试过这个结构,
...
def parse_second(self, response):
hxs = HtmlXPathSelector(response)
qqq = hxs.select('/html/head/link[@type=application/rss+xml]/@href').extract()
print qqq
item = response.request.meta['item']
if len(qqq) > 0:
item['rss'] = qqq.pop()
else:
item['rss'] = ''
yield item
...
但 “print qqq”给了我
[]
答案 0 :(得分:1)
发现错误:
qqq = hxs.select("/html/head/link[@type='application/rss+xml']/@href").extract()
有效