Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python从HTML提供URL_Python_Html Parsing_Urllib2 - Fatal编程技术网

使用Python从HTML提供URL

使用Python从HTML提供URL,python,html-parsing,urllib2,Python,Html Parsing,Urllib2,RSS提要URL可用于站点的元数据(如果可用)。有没有一种方法可以使用urlib2或HTMLParser模块提取页面的提要URL?还是有更好的模块可用 谢谢。我更喜欢。它有一个非常好的API,而且它的XPath支持使得实现这一点相当简单: import lxml.html doc = lxml.html.parse(url_to_site) feeds = doc.xpath('//link[@type="application/rss+xml"]/@href') # list feed url

RSS提要URL可用于站点的元数据(如果可用)。有没有一种方法可以使用
urlib2
HTMLParser
模块提取页面的提要URL?还是有更好的模块可用

谢谢。

我更喜欢。它有一个非常好的API,而且它的XPath支持使得实现这一点相当简单:

import lxml.html
doc = lxml.html.parse(url_to_site)
feeds = doc.xpath('//link[@type="application/rss+xml"]/@href') # list feed urls