📜  使用美丽的汤从 html 页面中提取基于 src 属性的图像 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:01.456000             🧑  作者: Mango

代码示例1
from urllib.request import urlopen
from bs4 import BeautifulSoup

site = "[insert name of the site]"
html = urlopen(site)
bs = BeautifulSoup(html, 'html.parser')

images = bs.find_all('img')
for img in images:
    if img.has_attr('src'):
        print(img['src'])