|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
python 写的
import requests
import json
import xlwt
def get_page(url):
headers={'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'}
resp=requests.get(url,headers=headers)
html=resp.text.strip('var CjnlcAlx=')
return html
def parser_html(html):
n=1
datas=json.loads(html)
text_json=datas['data']
print(text_json)
m=list(text_json[0].keys())
wb=xlwt.Workbook()
sht=wb.add_sheet('data',cell_overwrite_ok=True)
for j in range(len(text_json)):
for i in range(len(m)):
sht.write(0,i,m)
sht.write(n,i,text_json[j][m])
n+=1
wb.save('股票信息.xls')
def main():
url='http://data.eastmoney.com/DataCenter_V3/stock2016/jymx.ashx?pagesize=300&page=1&js=var%20CjnlcAlx¶m=&sortRule=-1&sortType=&gpfw=0&code=80479140&rt=25563331'
html=get_page(url)
parser_html(html)
main() |
评分
-
1
查看全部评分
-
|