Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16832

How to find img in main tag if main exist using beautifulsoup?

$
0
0

I want to know how to find all images in main tag if main tag exist ? except just find images that's in out of tag (I want to make an order to scrape images in main tag if exist and if there is no main tag scrape all images)

In fact I want to fillter header and footer tag and scrape all images in between.

if find('main'):    for link in soup.find('main').find_all('img'):        grabbedImages = link.get('src')else:    for link in soup.find_all('img'):        grabbedImages = link.get('src')

Thank you in advance for your guidance.


Viewing all articles
Browse latest Browse all 16832

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>