我试图从网站上得到的股票价值突出显示在框中的截图,但我写的代码没有显示任何输出。
感谢帮助获取红框中的数据。
截图:https://i.imgur.com/mHXpIYw.png
网址:https://marketsmithindia.com/mstool/eval/tvssrichak/evaluation.jsp#/
JSON:https://msi-gcloud-prod.appspot.com/gateway/simple-api/ms-india/instr/0/3023210/symboldetails.json?s=20180719&e=20230719&text=TVSSRICHAK&lang=en&isConsolidated=0&ms-auth=3990+MarketSmithINDUID-Web0000000000+MarketSmithINDUID-Web0000000000+0+230325200706+-514613229
Stocklist.txt:
TVSSRICHAK
INFY
SUZLON
字符串
代码:
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 24 23:14:57 2022
@author: eruku
"""
import requests
infile = 'c:/Users/eruku/Documents/StocksList.txt'
outfile = 'c:/Users/eruku/Documents/Marketsmithindia.txt'
timeout = 10
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) '
'Gecko/20100101 Firefox/73.0'
}
baseurl = 'https://msi-gcloud-prod.appspot.com/gateway/simple-api/ms-india/instr/0/3023210/symboldetails.json?s=20180719&e=20230719&text='
endurl = '&lang=en&isConsolidated=0&ms-auth=3990+MarketSmithINDUID-Web0000000000+MarketSmithINDUID-Web0000000000+0+230325200706+-514613229'
session = requests.Session()
response = session.get(baseurl, headers=headers, timeout=timeout)
with open(infile, 'r') as IN, open(outfile, 'w') as OUT:
for stock in IN:
stock = stock.strip()
response = session.get(
# f'{baseurl}api/quote-equity?symbol={stock}',
f'{baseurl}{stock}{endurl}',
headers=headers,
timeout=timeout
)
response = response.json()
型
1条答案
按热度按时间wr98u20j1#
这里有一个方法来获取这些信息:
字符串
终端结果:
型
你可以使用json数据,我刚刚举例说明了
quarterlySalesAndEarningsOrigin
。参见pandas和Requests的文档。