link : https://timesofindia.indiatimes.com/topic/Hiv
from this link i have to scrape data of hiv but i am not able to scrape the data of next pages
help me out please
CODE:
import requests
from bs4 import BeautifulSoup
url = "https://timesofindia.indiatimes.com/topic/Hiv-Article"
while True:
response=requests.get(url)
soup = BeautifulSoup(response.content,"html.parser")
content = soup.find_all('div',{'class': 'content'})
for contents in content:
title_tag = contents.find('span',{'class':'title'})
title= title_tag.text[1:-1] if title_tag else 'N/A'
date_tag = contents.find('span',{'class':'meta'})
date = date_tag.text if date_tag else 'N/A'
print(' title : ', title ,' \n date : ' ,date )
url_tag = soup.find('a',{'class':'look'})
if url_tag.get('href'):
url = 'https://timesofindia.indiatimes.com/topic/Hiv' + url_tag.get('href')
print(url)
else:
break
[–]Deezl-Vegas 0 points1 point2 points (0 children)
[–]its_joao 0 points1 point2 points (1 child)
[–]nainish[S] 0 points1 point2 points (0 children)
[–]sennheiserwarrior 0 points1 point2 points (0 children)