Closed c7h12 closed 2 years ago
遇到任何问题,请先确认您的 AKShare 版本是最新的
pip install akshare --upgrade # Python 版本需要大于 3.7
描述遇到的问题
- 操作系统版本
macos BigSur 11.6.8
- Python 版本
conda>Python 3.8.12
- AKShare 版本
1.7.22
- 接口的名称和代码
import akshare as ak print(ak.index_investing_global())
- 接口报错的截图或代码
In [1]: import akshare as ak In [2]: ak.__version__ Out[2]: '1.7.22' In [3]: ak.index_investing_global() --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [3], in <cell line: 1>() ----> 1 ak.index_investing_global() File ~/opt/miniconda3/envs/zero-dev/lib/python3.8/site-packages/akshare/index/index_investing.py:162, in index_investing_global(area, symbol, period, start_date, end_date) 160 end_date = "-".join([end_date[:4], end_date[4:6], end_date[6:]]) 161 period_map = {"每日": "Daily", "每周": "Weekly", "每月": "Monthly"} --> 162 name_code_dict = index_investing_global_area_index_name_code(area) 163 url = f"https://api.investing.com/api/financialdata/historical/{name_code_dict[symbol]}" 164 params = { 165 "start-date": start_date, 166 "end-date": end_date, 167 "time-frame": period_map[period], 168 "add-missing-rows": "false", 169 } File ~/opt/miniconda3/envs/zero-dev/lib/python3.8/site-packages/akshare/index/index_investing.py:89, in index_investing_global_area_index_name_code(area) 87 scraper = cfscrape.create_scraper(delay=10) 88 pd.set_option("mode.chained_assignment", None) ---> 89 name_url_dict = _get_global_country_name_url() 90 url = f"https://cn.investing.com{name_url_dict[area]}?&majorIndices=on&primarySectors=on&additionalIndices=on&otherIndices=on" 91 r = scraper.get(url) File ~/opt/miniconda3/envs/zero-dev/lib/python3.8/site-packages/akshare/index/index_investing.py:66, in _get_global_country_name_url() 64 res = session.post(url, headers=short_headers) 65 soup = BeautifulSoup(res.text, "lxml") ---> 66 name_url_option_list = soup.find( 67 "select", attrs={"name": "country"} 68 ).find_all("option")[ 69 1: 70 ] # 去掉-所有国家及地区 71 url_list = [item["value"] for item in name_url_option_list] 72 name_list = [item.get_text() for item in name_url_option_list] AttributeError: 'NoneType' object has no attribute 'find_all'
- 期望获得的正确结果
通过代理访问
遇到任何问题,请先确认您的 AKShare 版本是最新的
描述遇到的问题
print(ak.index_investing_global())
In [1]: import akshare as ak
In [2]: ak.version Out[2]: '1.7.22'
In [3]: ak.index_investing_global()
AttributeError Traceback (most recent call last) Input In [3], in <cell line: 1>() ----> 1 ak.index_investing_global()
File ~/opt/miniconda3/envs/zero-dev/lib/python3.8/site-packages/akshare/index/index_investing.py:162, in index_investing_global(area, symbol, period, start_date, end_date) 160 end_date = "-".join([end_date[:4], end_date[4:6], end_date[6:]]) 161 period_map = {"每日": "Daily", "每周": "Weekly", "每月": "Monthly"} --> 162 name_code_dict = index_investing_global_area_index_name_code(area) 163 url = f"https://api.investing.com/api/financialdata/historical/{name_code_dict[symbol]}" 164 params = { 165 "start-date": start_date, 166 "end-date": end_date, 167 "time-frame": period_map[period], 168 "add-missing-rows": "false", 169 }
File ~/opt/miniconda3/envs/zero-dev/lib/python3.8/site-packages/akshare/index/index_investing.py:89, in index_investing_global_area_index_name_code(area) 87 scraper = cfscrape.create_scraper(delay=10) 88 pd.set_option("mode.chained_assignment", None) ---> 89 name_url_dict = _get_global_country_name_url() 90 url = f"https://cn.investing.com{name_url_dict[area]}?&majorIndices=on&primarySectors=on&additionalIndices=on&otherIndices=on" 91 r = scraper.get(url)
File ~/opt/miniconda3/envs/zero-dev/lib/python3.8/site-packages/akshare/index/index_investing.py:66, in _get_global_country_name_url() 64 res = session.post(url, headers=short_headers) 65 soup = BeautifulSoup(res.text, "lxml") ---> 66 name_url_option_list = soup.find( 67 "select", attrs={"name": "country"} 68 ).find_all("option")[ 69 1: 70 ] # 去掉-所有国家及地区 71 url_list = [item["value"] for item in name_url_option_list] 72 name_list = [item.get_text() for item in name_url_option_list]
AttributeError: 'NoneType' object has no attribute 'find_all'