Как сохранить все картинки, а именно .png
, которые находятся на странице? Мой код не работает:
import requests
from bs4 import BeautifulSoup
response = requests.get("https://www.soccerstand.com/ru/match/4haX78Hq/#/match-summary")
soup = BeautifulSoup(response.content, "html.parser")
images = [img for img in soup.find_all("img") if ".png" in img.get("src")]
for i, image in enumerate(images):
img_data = requests.get(image["src"]).content
with open(f"image_{i}.png", "wb") as f:
f.write(img_data)