How to use beautifulSoup to get the image from a webpage

Submitted 3 years, 7 months ago
Ticket #368
Views 388
Language/Framework Python
Priority Low
Status Closed

I am newbie to python. It would be great if someone help to create the high level script to get the image from webpage using Python beatifulSoup.

Thanks in advance.

Submitted on Mar 04, 21

did you check the solution provided by our SME. Do let us know if your issue is resolved. - revathirv 3 years, 6 months ago
add a comment

1 Answer

Verified

PFB the some sample code,

from bs4 import BeautifulSoup
import requests
url = 'http://www.prnewswire.com/news-releases/dutch-philosopher-koert-van-mensvoort-founder-of-the-next-nature-network-writes-a-letter-to-humanity-619925063.html'
r = requests.get(url)
html = r.text
soup = BeautifulSoup(html, 'lxml')
links = soup.find_all('div', {'class': 'image'})
print [i.find('img')['src'] for i in links]
print [i.find('img')['title'] for i in links]

check this and let me know.

Submitted 3 years, 7 months ago

Thanks.

- kapjakal 3 years, 6 months ago


Latest Blogs