使用Python下載雅虎財務(wù)數(shù)據(jù)

我有這個代碼,但它不工作,我不知道為什么…請幫助!

import numpy as np
import pandas as pd
from pandas_datareader import data
TSLA = data.DataReader('TSLA', 'yahoo', start='2020-01-01')
print("TSLA:",TSLA)
Traceback (most recent call last):
  File "C:\Users\David\Desktop\david\Sona\Python\PRUEBA.py", line 4, in <module>
    TSLA = data.DataReader('TSLA', 'yahoo', start='2020-01-01')
  File "C:\Users\David\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\util\_decorators.py", line 208, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\David\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas_datareader\data.py", line 384, in DataReader
    session=session,
  File "C:\Users\David\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas_datareader\base.py", line 253, in read
    df = self._read_one_data(self.url, params=self._get_params(self.symbols))
  File "C:\Users\David\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas_datareader\yahoo\daily.py", line 153, in _read_one_data
    resp = self._get_response(url, params=params)
  File "C:\Users\David\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas_datareader\base.py", line 181, in _get_response
    raise RemoteDataError(msg)
pandas_datareader._utils.RemoteDataError: Unable to read URL: https://finance.yahoo.com/quote/TSLA/history?period1=1577847600&period2=1667185199&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="http://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="http://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>'

Thanks!!

我想用我的代碼解決一個問題

? 最佳回答:
import numpy as np
import pandas as pd
from pandas_datareader import data

TSLA = data.get_data_yahoo('TSLA', start='2020-01-01')
print("TSLA:",TSLA)

Output

                Open       High      Low        Close       Adj Close    Volume
Date                        
2020-01-02  28.299999   28.713333   28.114000   28.684000   28.684000   142981500
2020-01-03  29.366667   30.266666   29.128000   29.534000   29.534000   266677500
2020-01-06  29.364668   30.104000   29.333332   30.102667   30.102667   151995000
2020-01-07  30.760000   31.441999   30.224001   31.270666   31.270666   268231500
2020-01-08  31.580000   33.232666   31.215334   32.809334   32.809334   467164500
... ... ... ... ... ... ...
2022-10-24  205.820007  213.500000  198.589996  211.250000  211.250000  100446800
2022-10-25  210.100006  224.350006  210.000000  222.419998  222.419998  96507900
2022-10-26  219.399994  230.600006  218.199997  224.639999  224.639999  85012500
2022-10-27  229.770004  233.809998  222.850006  225.089996  225.089996  61638800
2022-10-28  225.399994  228.860001  216.350006  228.520004  228.520004  69039900

如果錯誤仍然存在,請嘗試升級庫

pip install --upgrade pandas-datareader
主站蜘蛛池模板: 免费一区二区视频| 国产精品资源一区二区| 一区二区三区免费精品视频 | 亚洲午夜精品一区二区| 亚洲国产精品无码久久一区二区 | 久久一区二区三区免费播放| 国产无套精品一区二区| 在线精品亚洲一区二区小说| 精品一区二区三区中文字幕| 无码毛片视频一区二区本码| 亚洲AV日韩综合一区尤物| 天堂va视频一区二区| 亚洲Aⅴ无码一区二区二三区软件| 国产乱码精品一区二区三| 无码一区二区三区免费| 亚洲无码一区二区三区| 国产剧情一区二区| 国精品无码一区二区三区在线| 亚洲AV福利天堂一区二区三 | 乱色精品无码一区二区国产盗| 亚洲乱码av中文一区二区| 精彩视频一区二区| 亚洲AV无码一区东京热久久| 99精品国产一区二区三区2021| 视频在线观看一区二区三区| 中文日韩字幕一区在线观看| 国产美女一区二区三区| av在线亚洲欧洲日产一区二区| 无码人妻精品一区二区三区夜夜嗨 | 国产精品免费一区二区三区| 精品无码一区二区三区爱欲九九| 日韩美女在线观看一区| 久久精品视频一区二区三区| 日本精品视频一区二区| 亚欧色一区W666天堂| 精品一区二区三区四区电影| 亚洲bt加勒比一区二区| 内射白浆一区二区在线观看| 日韩免费无码一区二区三区| 国产福利电影一区二区三区,亚洲国模精品一区 | 亚洲AV无一区二区三区久久|