2010-07-29 27 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() 

的作品