This is the code that wrote to fetch data from webpage:
import urllib.request import urllib from bs4 import BeautifulSoup
def make_soup(url):
req=urllib.request.Request(url,headers={'User-Agent': 'Mozilla/5.0'})
thepage=urllib.request.urlopen(req)
soupdata=BeautifulSoup(thepage,'html5lib')
return soupdata
soup=make_soup("https://www.nseindia.com/live_market/dynaContent/live_analysis/top_gainers_losers.htm?cat=G")
t=soup.findAll('table')[0]
for record in t.findAll('tr'):
print(record.td.text)
'''
for record in t.findAll('tr'):
for data in record.findAll('td'):
print(data.text)
'''
But this code fetches only first tr. how to get values for remaining tr