我有一个这样的字符串
http://example.com/path/topage.htmlhttp://twitter.com/p/xyanhshttp://httpget.org/get.zipwww.google.com/privacy.htmlhttps://goodurl.net/
我想提取所有的网址/网页地址到一个数组。例如
urls = ['http://example.com/path/topage.html','http://twitter.com/p/xyan',.....]
这是我的方法,但没有奏效。
import re
strings = "http://example.com/path/topage.htmlhttp://twitter.com/p/xyanhshttp://httpget.org/get.zipwww.google.com/privacy.htmlhttps://goodurl.net/"
links = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', strings)
print links
// result always same as strings
https://stackoverflow.com/questions/38730782
复制相似问题