Page 1 of 1

Wie speichern Sie Bilder in einem Ordner aus Web -Scraping? (Python)

Posted: 28 Feb 2025, 06:00
by Anonymous
Wie mache ich es so, dass jedes Bild, das ich aus Web -Scraping erzielt habe, dann in einem Ordner gespeichert wird? Ich benutze Google Colab derzeit, da ich nur Sachen übe. Ich möchte sie in meinem Google Drive -Ordner speichern.

Code: Select all

import requests
from bs4 import BeautifulSoup

def getdata(url):
r = requests.get(url)
return r.text

htmldata = getdata('https://www.yahoo.com/')
soup = BeautifulSoup(htmldata, 'html.parser')

imgdata = []
for i in soup.find_all('img'):
imgdata = i['src']
print(imgdata)