News Web Scraping
from urllib.request import urlopen
from bs4 import BeautifulSoup as soup
url="https://www.indiatoday.in/latest-headlines"
uclient = urlopen(url)
#uclient
page_html = uclient.read()
#page_html
page_soup = soup(page_html,"html.parser")
#page_soup
articles = page_soup.find("div",{"class":"view-content"}).findAll("div",{"class":"catagory-listing"})
#len(articles)
#articles
i=1
for x in articles:
title=x.find("h2").text
para = x.find("p").text
print("(",i,")",title)
print()
print(para)
print()
print()
i=i+1
Last updated