我想提取rvry链接在我的文件文本文件与http或https或没有
我试过很多代码,但我不能使用其中的
import re
with open("path\url_example.txt") as file:
for line in file:
urls = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', line)
print(urls)但是我的链接并不是从http://www开始的。或者https://www。和
发布于 2020-04-13 02:51:53
如果您有不同的协议,则可以使用此正则表达式:
(.*:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&//=]*)https://stackoverflow.com/questions/61176327
复制相似问题