0

Here is my code. Please see the code and tell me what is not correct in this code and tell me the solution.

import pandas_datareader.data as web
import datetime

start = datetime.datetime(2015, 1, 1)
end = datetime.datetime(2018, 2, 8)

df = web.DataReader('TSLA', 'google', start, end)

print(df.head())

This is the exception:

C:\Users\Sales\Desktop\Chart\venv\Scripts\python.exe C:/Users/Sales/Desktop/Chart/charts/chart1.py
C:\Users\Sales\Desktop\Chart\venv\lib\site-packages\pandas_datareader\google\daily.py:40: UnstableAPIWarning: 
The Google Finance API has not been stable since late 2017. Requests seem
to fail at random. Failure is especially common when bulk downloading.

warnings.warn(UNSTABLE_WARNING, UnstableAPIWarning)
Traceback (most recent call last):
File "C:/Users/Sales/Desktop/Chart/charts/chart1.py", line 8, in <module>
df = web.DataReader('TSLA', 'google', start, end)
File "C:\Users\Sales\Desktop\Chart\venv\lib\site-packages\pandas_datareader\data.py", line 315, in DataReader
session=session).read()
File "C:\Users\Sales\Desktop\Chart\venv\lib\site-packages\pandas_datareader\base.py", line 206, in read
params=self._get_params(self.symbols))
File "C:\Users\Sales\Desktop\Chart\venv\lib\site-packages\pandas_datareader\base.py", line 84, in _read_one_data
out = self._read_url_as_StringIO(url, params=params)
File "C:\Users\Sales\Desktop\Chart\venv\lib\site-packages\pandas_datareader\base.py", line 95, in _read_url_as_StringIO
response = self._get_response(url, params=params)
File "C:\Users\Sales\Desktop\Chart\venv\lib\site-packages\pandas_datareader\base.py", line 155, in _get_response
raise RemoteDataError(msg)
pandas_datareader._utils.RemoteDataError: Unable to read URL: https://finance.google.com/finance/historical?q=TSLA&startdate=Jan+01%2C+2018&enddate=Feb+08%2C+2018&output=csv
Response Text:
b'<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>Sorry...</title><style> body { font-family: verdana, arial, sans-serif; background-color: #fff; color: #000; }</style></head><body><div><table><tr><td><b><font face=sans-serif size=10><font color=#4285f4>G</font><font color=#ea4335>o</font><font color=#fbbc05>o</font><font color=#4285f4>g</font><font color=#34a853>l</font><font color=#ea4335>e</font></font></b></td><td style="text-align: left; vertical-align: bottom; padding-bottom: 15px; width: 50%"><div style="border-bottom: 1px solid #dfdfdf;">Sorry...</div></td></tr></table></div><div style="margin-left: 4em;"><h1>We\'re sorry...</h1><p>... but your computer or network may be sending automated queries. To protect our users, we can\'t process your request right now.</p></div><div style="margin-left: 4em;">See <a href="https://support.google.com/websearch/answer/86640">Google Help</a> for more information.<br/><br/></div><div style="text-align: center; border-top: 1px solid #dfdfdf;"><a href="https://www.google.com">Google Home</a></div></body></html>'
  • Please include the full exception, not just the description. In this case, because your problem happens to be an exact duplicate of an existing question, you were lucky and got an answer, but in general, it's very hard to debug what caused an exception without the information contained in that traceback. – abarnert Jul 02 '18 at 20:55
  • I updated the exception, please see and I tried to follow the answer whatever is given in previous asked question but it gives me an error after that. Error is: "AttributeError("module 'pandas_datareader.data' has no attribute 'Datareader'",) " – Ravindra Kumar Jul 02 '18 at 21:11

0 Answers0