I want to extract news headlines from Hindustantimes.com. I have the following code but i get the data in different columns in the same row. I want each news on separate line. Can anyone please help me. Thanks in advance. Here is my code:
import requests
import bs4
import csv
res=requests.get('https://www.hindustantimes.com')
soup=bs4.BeautifulSoup(res.text,'lxml')
x=[]
for i in soup.select('div.subhead4'):
x.append(i.text)
for i in soup.select('div.bigstory-mid-h3'):
x.append(i.text)
for i in x:
print(i)
with open('newz.csv','w') as cF:
wr = csv.writer(cF)
wr.writerow(x)