相关疑难解决方法(0)

正则表达式使用Python从HTML中的href属性中提取URL

可能重复:
检查字符串是否为有效URL的最佳正则表达式是什么?

考虑如下字符串:

string = "<p>Hello World</p><a href="http://example.com">More Examples</a><a href="http://example2.com">Even More Examples</a>"
Run Code Online (Sandbox Code Playgroud)

我怎么能用Python在锚标记的href中提取网址?就像是:

>>> url = getURLs(string)
>>> url
['http://example.com', 'http://example2.com']
Run Code Online (Sandbox Code Playgroud)

谢谢!

python regex url

79
推荐指数
2
解决办法
14万
查看次数

标签 统计

python ×1

regex ×1

url ×1