1

我想解析 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
...

但是“打印qqq”给了我

[]
4

1 回答 1

1

发现一个错误:

qqq = hxs.select("/html/head/link[@type='application/rss+xml']/@href").extract()

这样可行

于 2010-07-29T12:06:59.853 回答