【问题标题】:How to parse RSS link (get ulr to RSS) from the page in Python framework Scrapy?如何从 Python 框架 Scrapy 中的页面解析 RSS 链接(获取 RSS 的 URL)?
【发布时间】:2010-07-29 11:50:46
【问题描述】:

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

[]

【问题讨论】:

  • 能否包含一个您尝试匹配的 HTML 示例?

标签: python xpath rss parsing scrapy


【解决方案1】:

发现一个错误:

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

有效

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-04
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 2019-08-25
    相关资源
    最近更新 更多