使用Python正则表达式从文章中取出所有图片路径
使用Python正则表达式从文章中取出所有图片路径
import re
name = '''you test this is for mae <img src="/upload/images/123455.jpg"/>, test for you just liook <img src="/upload/images/1test455.jpg"/>'''
result = re.findall('<img src="(.*?)"/>', name, re.S)
print result
结果为:
['/upload/images/123455.jpg', '/upload/images/1test455.jpg']
当然如何你的img标签和src属性之间还有其他属性, 则你也可以直接取src, 如:
result = re.findall('src="(.*?)"/>', name, re.S)
查看更多关于使用Python正则表达式从文章中取出所有图片路径的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did43922