正则表达式在html中找到<img src="url"/>

时间:2013-03-07 19:05:46

标签: python regex urllib2

我还没有使用正则表达式,并且正在寻找帮助来找到字符串中的部分。

img标签示例:

<img border="0" alt="background, images, scarica, adobe, art, rainbow, colorful, wallpaper, tutorial, abstract, photoshop, web, pictures, wallpapers" width="192" height="120" class="h_120" src="http://static.hdw.eweb4.com/media/thumbs/1/74/736679.jpg" />

我只是想从一个大的html文件中获取src的url。

1 个答案:

答案 0 :(得分:2)

使用BeautifulSoup

from bs4 import BeautifulSoup

soup = BeautifulSoup(html_doc)
page_images = [image["src"] for image in soup.findAll("img")]

使用:BeautifulSoup

安装pip install beautifulsoup4
相关问题