I m just started learning web scraping using Python. My aim is to web scrape the Realtime news for Bajaj Auto Ltd. from http://money.rediff.com/companies/Bajaj-Auto-Ltd/10540026.
The problem: I'm unable to extract the contents(i.e news).
from urllib.request import urlopen
from bs4 import BeautifulSoup
url = 'http://money.rediff.com/companies/Bajaj-Auto-Ltd/10540026'
data = urlopen(url)
soup = BeautifulSoup(data)
te=soup.find('a',attrs={'target':'_jbpinter'})
lis=te.find_all_next('a',attrs={'target':'_jbpinter'})
#print(lis)
for li in lis:
print(li.find('a').contents[0])
I m getting the error "AttributeError: 'NoneType' object has no attribute 'contents'" And I does not get the desired result.
Any input will be appreciated.
liand see if there is actually anain there