赞
踩
利用re的不分组(?:pattern)和N选1(?: (?:pattern1)|(?:pattern2)|(?:pattern3)),一次性筛选出符合三种格式的链接
res = re.findall(r'"((?:(?:ed2k)|(?:magnet)|(?:thunder)):.+?)"',content) # 批量链接["..."]
res = re.findall(r'((?:(?:ed2k)|(?:magnet)|(?:thunder)):.+?)[\s]',content) # 批量非链接[ed2k mag1 \n mag2]
res = re.findall(r'((?:(?:ed2k)|(?:magnet)|(?:thunder)):.+)',content) # 单条非链接
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。