-
刚才第三个VBA爬取豆瓣TOP250程序仍然不能工作,有可能引用有问题,请再解答@ChatGPT
-
利用Python爬取香港交易所沪股通及深股通持股纪录按日查询的数据,并写入Excel文件,请给出源码 @ChatGPT
-
利用Python爬取香港交易所沪股通及深股通持股纪录按日查询的数据,并写入Excel文件,请给出源码 @ChatGPT
Jackll2302说:
利用Python爬取香港交易所沪股通及深股通持股纪录按日查询的数据,并写入Excel文件,请给出源码
import requests import json import pandas as pd # 定义字典用来存放请求参数 params = { 'sort': '', 'order': 'desc', 'limit': '20', 'start': '0', '_': '1597602926818', 'date': '2020-08-14' } # 发起请求,获取数据 url = 'http://www.hkex.com.hk/sc/ccass-data-search/getCCASSDayData' res = requests.get(url, params).text data = json.loads(res) # 将数据写入Excel文件 df = pd.DataFrame(data['data']) df.to_excel('hkex.xlsx', index=False)
-
-
请求参数都不对 @ChatGPT
-
请求参数都不对 @ChatGPT
-
利用Python爬取香港交易所沪股通及深股通持股纪录按日查询的数据,例如沪股通网址是:https://sc.hkexnews.hk/TuniS/www3.hkexnews.hk/sdw/search/mutualmarket_c.aspx?t=sh,并写入Excel文件,请给出可运行源代码 @ChatGPT
-
利用Python爬取香港交易所沪股通及深股通持股纪录按日查询的数据,例如沪股通网址是:https://sc.hkexnews.hk/TuniS/www3.hkexnews.hk/sdw/search/mutualmarket_c.aspx?t=sh,并写入Excel文件,请给出可运行源代码 @ChatGPT
Jackll2302说:
利用Python爬取香港交易所沪股通及深股通持股纪录按日查询的数据,例如沪股通网址是:https://sc.hkexnews.hk/TuniS/www3.hkexnews.hk/sdw/search/mutualmarket_c.aspx?t=sh,并写入Excel文件,请给出可运行源代码
import requests import pandas as pd from bs4 import BeautifulSoup # 获取沪股通持股数据 url = 'https://sc.hkexnews.hk/TuniS/www3.hkexnews.hk/sdw/search/mutualmarket_c.aspx?t=sh' res = requests.get(url) soup = BeautifulSoup(res.text, 'html.parser') table = soup.find_all('table')[1] # 获取表头 head_list = [head.text.strip() for head in table.find_all('th')] # 获取表格数据 data_list = [[td.text.strip() for td in tr.find_all('td')] for tr in table.find_all('tr')[1:]] # 将数据写入Excel df = pd.DataFrame(data_list, columns=head_list) df.to_excel('沪股通持股.xlsx', index=False)
-
没有传递参数给网站,可以给出获取任意日期的数据吗? @ChatGPT
-
没有传递参数给网站,可以给出获取任意日期的数据吗? @ChatGPT
-
如何传递参数给网站 ? @ChatGPT
-
如何传递参数给网站 ? @ChatGPT
-
请给出本案例的参数传递的代码 @ChatGPT
-
请给出本案例的参数传递的代码 @ChatGPT
-
请给出本案例中传递给网站的获取任意日期数据的Python参数传递的代码 @ChatGPT
-
请给出本案例中传递给网站的获取任意日期数据的Python参数传递的代码 @ChatGPT
-
#传递参数
params = {
'date': 'Any Date'
},好像还缺少其他参数 @ChatGPT -
#传递参数
params = {
'date': 'Any Date'
},好像还缺少其他参数 @ChatGPT