D
D
deadlymouse142212020-04-03 16:51:59
Python
deadlymouse14221, 2020-04-03 16:51:59

How to download a picture using BeautifulSoup?

How to download a picture using BeautifulSoup is necessary for the parser

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tiger_13, 2020-04-03
@deadlymouse14221

r = requests.get("xxx")
soup = BeautifulSoup(r.content)
for link in soup.select("img[src^=http]"):
        lnk = link["src"]
        with open(basename(lnk)," wb") as f:
            f.write(requests.get(lnk).content)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question