I have a situation where I am not able to parse data from following link for example:
https://www.bseindia.com/stock-share-price/avanti-feeds-ltd/avanti/512573/
From this webpage I want to populate High Lows table. I tried many combinations of table and div but in vain. Below is my python beautifulsoup code (BS4)
import csv
import requests
import urllib.request
import urllib.parse
from bs4 import BeautifulSoup
f = open('bse.csv', 'w', newline = '')
writer = csv.writer(f)
with open("bselist.csv") as f:
for row in csv.reader(f):
for stock in row:
url = "https://www.bseindia.com/stock-share-price/{}".format(stock)
soup = BeautifulSoup(urllib.request.urlopen(url).read(), "lxml")
mydivs = soup('div', {"class": "newscripcotent5"})[0].find_all('span')
writer.writerow([stock] + mydivs)
print([stock] + mydivs)
URL for simplicity I have given direct link to one of the records contained in the file bselist.csv. I am looking for div id "highlow"
It just gives me following output
avanti-feeds-ltd/avanti/512573/
without any table I am looking for.
Output should be ideally somewhat like following:
avanti-feeds-ltd/avanti/512573/ 52 Week High (adjusted) 999.00(13/11/2017)
avanti-feeds-ltd/avanti/512573/ 52 Week Low (adjusted) 410.26(05/06/2018)
avanti-feeds-ltd/avanti/512573/ 52 Week High (Unadjusted) 3,000.00(13/11/2017)
avanti-feeds-ltd/avanti/512573/ 52 Week Low (Unadjusted) 535.50(29/06/2018)
avanti-feeds-ltd/avanti/512573/ Month H/L 659.34/410.26
avanti-feeds-ltd/avanti/512573/ Week H/L 625.25/508.82