正则表达式查找 <img src='url' /> in HTML



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

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。

使用BeautifulSoup:

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

安装BeautifulSoup: pip install beautifulsoup4

最新更新