2010-07-29 58 views
1

我想解析Google搜索并从搜索结果中的每个项目获取指向RSS的链接。 我使用Scrapy。 我试过这种结构,如何在Python框架Scrapy中解析RSS链接(从ulr到RSS)?

... 
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” 给我

[] 
+0

您可以包括的样本你试图匹配的HTML? – MattH 2010-07-29 12:06:09

回答

1

发现了一个错误:

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

的作品