首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >熊猫--无法从雅虎金融公司调出数据--无法阅读url并错误地写着“我们的工程师正在研究”。

熊猫--无法从雅虎金融公司调出数据--无法阅读url并错误地写着“我们的工程师正在研究”。
EN

Stack Overflow用户
提问于 2022-03-31 16:21:22
回答 1查看 601关注 0票数 1

我只是在做一个简单的项目,试图使用熊猫数据器从雅虎财务中提取股票数据,代码发回一个错误,我将在下面发布:

代码语言:javascript
复制
pandas_datareader._utils.RemoteDataError: Unable to read URL: https://finance.yahoo.com/quote/AAPL/history?period1=1577869200&period2=1648799999&interval=1d&frequency=1d&filter=history
Response Text:
b'<!DOCTYPE html>\n  <html lang="en-us"><head>\n  <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n      <meta charset="utf-8">\n      <title>Yahoo</title>\n      <meta name="viewport" content="width=device-width,initial-scale=1,minimal-ui">\n      <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\n      <style>\n  html {\n      height: 100%;\n  }\n  body {\n      background: #fafafc url(https://s.yimg.com/nn/img/sad-panda-201402200631.png) 50% 50%;\n      background-size: cover;\n      height: 100%;\n      text-align: center;\n      font: 300 18px "helvetica neue", helvetica, verdana, tahoma, arial, sans-serif;\n  }\n  table {\n      height: 100%;\n      width: 100%;\n      table-layout: fixed;\n      border-collapse: collapse;\n      border-spacing: 0;\n      border: none;\n  }\n  h1 {\n      font-size: 42px;\n      font-weight: 400;\n      color: #400090;\n  }\n  p {\n      color: #1A1A1A;\n  }\n  #message-1 {\n      font-weight: bold;\n      margin: 0;\n  }\n  #message-2 {\n      display: inline-block;\n      *display: inline;\n      zoom: 1;\n      max-width: 17em;\n      _width: 17em;\n  }\n      </style>\n  <script>\n    document.write(\'<img src="//geo.yahoo.com/b?s=1197757129&t=\'+new Date().getTime()+\'&src=aws&err_url=\'+encodeURIComponent(document.URL)+\'&err=%<pssc>&test=\'+encodeURIComponent(\'%<{Bucket}cqh[:200]>\')+\'" width="0px" height="0px"/>\');var beacon = new Image();beacon.src="//bcn.fp.yahoo.com/p?s=1197757129&t="+new Date().getTime()+"&src=aws&err_url="+encodeURIComponent(document.URL)+"&err=%<pssc>&test="+encodeURIComponent(\'%<{Bucket}cqh[:200]>\');\n  </script>\n  </head>\n  <body>\n  <!-- status code : 404 -->\n  <!-- Not Found on Server -->\n  <table>\n  <tbody><tr>\n      <td>\n      <img src="https://s.yimg.com/rz/p/yahoo_frontpage_en-US_s_f_p_205x58_frontpage.png" alt="Yahoo Logo">\n      <h1 style="margin-top:20px;">Will be right back...</h1>\n      <p id="message-1">Thank you for your patience.</p>\n      <p id="message-2">Our engineers are working quickly to resolve the issue.</p>\n      </td>\n  </tr>\n  </tbody></table>\n  </body></html>'

我从2021年7月开始在所有论坛上寻找解决方案,发现这是个问题,但我现在就明白了。我使用了所有的解决方案,更新了我的熊猫数据中心,以确保它是正确的版本,甚至pip卸载和pip重新安装所有的软件包和库。似乎什么都没起作用。没有论坛的解决方案有效。奇怪的是,当我通过命令提示符运行脚本时,它可以工作,并且能够提取数据,但不能在我的IDE (即Visual代码)中提取数据。这是否意味着问题在于Visual代码?请帮忙,因为这个项目即将到期日。我会继续监察这篇文章,以回答任何跟进问题。谢谢!

EN

回答 1

Stack Overflow用户

发布于 2022-03-31 19:35:03

关于这个错误,熊猫数据中心项目中有最近的、悬而未决的问题

也就是说,下面的代码段会产生观察到的错误:

代码语言:javascript
复制
from pandas_datareader import data as pdr
data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")

这里有两个解决方案。如果您想坚持使用熊猫数据中心,您可以尝试下面的代码,它是从这个职位改编的。

代码语言:javascript
复制
from pandas_datareader import data as pdr

import yfinance as yf
yf.pdr_override()

# download dataframe using pandas_datareader
data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")

甚至更简单的是,纯yfinance版本:

代码语言:javascript
复制
import yfinance as yf
data = yf.download("SPY", start="2017-01-01", end="2017-04-30")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71696014

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档