take the contents of a tag without taking the contents of its child in web scraping using python

You can remove unwanted tag using .extract():

soup = bs4.BeautifulSoup(page.content, 'html.parser')
news = soup.find('div',{'class': 'col-md-8 left-container details'})
News_article = news.find_all('div',{'class': 'news-article'})
ads = soup.find_all('div',class_='ads')
for x in ads: 

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top