1 year ago

#26774

test-img

Ravi

Able to extract only one page (~50 items) and not all data for a date from API of BSE using python code. Earlier I used to get all data for a date

I have been accessing info from an API of BSE using python code. It used to pull all announcements, but now Iam getting only 1 page of these (~ 50). Not sure if problem with parameters or some change at backend. my knowledge of python is limited.

import time
import requests'
from datetime import date'
#api from which I want to extract data for a specific date
url = 'https://api.bseindia.com/BseIndiaAPI/api/AnnGetData/w'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
AppleWebKit/537.36 (KHTML, 
like Gecko) Chrome/73.0.3683.103 Safari/537.36'}
payload = {
'strCat': '-1',
'strPrevDate': '20220108',
'strScrip': '',
'strSearch': 'P',
'strToDate': '20220108',
'strType': 'C'}
ftest=open("ftest.txt",'w',encoding='utf-8')
jsonData = requests.get(url, headers=headers, params=payload).json()
for article in jsonData['Table']:
    nsub = article['NEWSSUB']`
    hsub = article['HEADLINE']
    csub = article['CATEGORYNAME']
    cmore = article['MORE']
    dttm = article['DissemDT']
    tm=dttm[11:15:1]
    ftest.write('%s:%s\n' %(tm,nsub))
    # write data to a file 
ftest.close()

python

json

api

stock

self-extracting

0 Answers

Your Answer

Accepted video resources