Pandas-datareader not able to pull from yahoo finance- unable to read url with response text in error saying "our engineers are working on it" - yahoo-finance

I was just working on a simple project trying to pull stock data from yahoo finance using pandas-datareader and the code send back an error which I will post below:
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>'
I looked all over forums to find a solution and saw this was a problem from July of 2021, but I am getting it now. I employed all the solutions, updating my pandas-datareader to make sure it was the right version, even pip uninstalling and pip installing all the packages and libraries again. Nothing seems to be working. No forums solutions work. Oddly enough when I run the scripts through command prompt it works and is able to pull data but not in my IDE which is Visual Studio Code. Does that mean the problem is with Visual Studio Code? Please help as this project is due very soon. I will keep monitoring this post to answer any follow up questions. Thanks!

There are fairly recent, open issues in the pandas datareader project regarding this error.
That is, the following snippet yields the observed errors:
from pandas_datareader import data as pdr
data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")
Here are two solutions. If you want to stick to the pandas datareader, you can try out the code below, which was adapted from this post:
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")
Or even easier, the pure yfinance version:
import yfinance as yf
data = yf.download("SPY", start="2017-01-01", end="2017-04-30")

Related

Specific material icon is not showing offline

My angular application is hosted on a server with no internet connection, because of that, I removed the following code from my index.html:
<link href="https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp" rel="stylesheet">
And downloaded them via npm: npm install material-design-icons --save
And added them like this in my idex.html :
<link rel="stylesheet" href="node_modules/material-design-icons-iconfont/dist/material-design-icons.css">
Everything seems fine, mostly of the icons work except for this one:
No matter if I use it like this:
<span class="material-icons">
read_more
</span>
or this
<mat-icon
read_more
</mat-icon>
or even as the character code, since I thought it has something todo with ligatures (I took the code from here https://github.com/google/material-design-icons/blob/master/font/MaterialIcons-Regular.codepoints)
<mat-icon>

</mat-icon>
It does work if I use <link href="https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp" rel="stylesheet"> in my index.html and have an internet connection, but I need to find a way for it to work without an internet connection.
Has anybody an idea?
I solved my problem by using "fontface": https://github.com/fontsource/fontsource
I installed int by using npm install #fontsource/material-icons, this adds the following folder:
I replaced added in my main style file with the following:
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;
/* Support for Firefox. */
-moz-osx-font-smoothing: grayscale;
/* Support for IE. */
font-feature-settings: 'liga';
}
And in my main styles file (I use scss) I added the following:
#import "~#fontsource/material-icons/index.css";
That did the trick for me. I also were able to use the icon without the code:
<mat-icon>read_more</mat-icon>
Try to add it in angular.json rather than index.html. Also, check if that icon is available in the version you have downloaded. Try to downgrade the package and run the npm install command.

Azure function activity in ADF V2 timeouts after 4min 7sec, even though in code i have mentioned "functionTimeout": "00:10:00" which is 10mins?

I have created an azure function and its timeout is set to 10mins in hosts.json but when I am triggering it through ADF V2 azure function activity then activity is getting terminated after 4mins 7sec, Can any one guide me what is happening at the backend and why I am getting this behavior? Thanks.
Update: If i run my azure function through ADF or from postman it gives me this error after 4min 7sec:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>502 - Web server received an invalid response while acting as a gateway or proxy server.</title>
<style type="text/css">
< !-- body {
margin: 0;
font-size: .7em;
font-family: Verdana, Arial, Helvetica, sans-serif;
background: #EEEEEE;
}
fieldset {
padding: 0 15px 10px 15px;
}
h1 {
font-size: 2.4em;
margin: 0;
color: #FFF;
}
h2 {
font-size: 1.7em;
margin: 0;
color: #CC0000;
}
h3 {
font-size: 1.2em;
margin: 10px 0 0 0;
color: #000000;
}
#header {
width: 96%;
margin: 0 0 0 0;
padding: 6px 2% 6px 2%;
font-family: "trebuchet MS", Verdana, sans-serif;
color: #FFF;
background-color: #555555;
}
#content {
margin: 0 0 0 2%;
position: relative;
}
.content-container {
background: #FFF;
width: 96%;
margin-top: 8px;
padding: 10px;
position: relative;
}
-->
</style>
</head>
<body>
<div id="header">
<h1>Server Error</h1>
</div>
<div id="content">
<div class="content-container">
<fieldset>
<h2>502 - Web server received an invalid response while acting as a gateway or proxy server.</h2>
<h3>There is a problem with the page you are looking for, and it cannot be displayed. When the Web
server (while acting as a gateway or proxy) contacted the upstream content server, it received an
invalid response from the content server.</h3>
</fieldset>
</div>
</div>
</body>
</html>
And if I go to App insights of function App it shows me timeout of 10mins which I think is correct because I am using consumption plan so I know that. But at 4min and 7sec the 502 response which is sent to the client i am not familier with issue. Please guide.
As your function can continue to run as expected even though the 502 error shows, so I think it has nothing to do with your azure function.
As far as I know, azure function activity just allows 230 seconds for the request in data factory. You can refer to this document.
If you want to request it by postman, you can set the "request time out" in the "settings" of your postman. Please refer to this document.
Hope it helps~
Maybe just me, but if true that you are limited to 230 seconds then this is CRAZY. I can definitely run functions for longer than that. In consumption plan up to 10 minutes, in premium plan you can have 60 minutes run time. See here.
If the answer is to use Durable function, then you might as well just implement your workflow in there and forget about ADF completely.
Azure Function ADF Activity tool-tip states that default timeout is 12 hours.
Something doesn't smell right.

How to make Bottle print error message in 500 response?

I'm trying to debug why Bottle can no longer find a template, but it doesn't tell me which template is actually missing:
File "/virtualenv/lib/python2.7/site-packages/bottle.py", line 3222, in __init__
raise TemplateError('Template %s not found.' % repr(name))
bottle.TemplateError
Neither the console nor the web page contain the formatted version of Template %s not found. anywhere.
I have enabled debugging (when debugging is disabled the stack trace does not show up on the web page).
The route handler is literally just #bottle.post('/request').
This is distinct from How to make Bottle print stacktrace when running through apache modwsgi?, since the answer there is to enable debugging.
Using the latest stable Bottle, 0.12.13.
This works for me - is your code substantially different? Hoping you'll spot a difference.
from bottle import Bottle, template
app = Bottle()
#app.route('/')
def home():
return template('foo') # template "foo" does not exist
app.run(host='127.0.0.1', port=8080) # Note: no debug required
Response:
% curl http://127.0.0.1:8080/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>Error: 500 Internal Server Error</title>
<style type="text/css">
html {background-color: #eee; font-family: sans;}
body {background-color: #fff; border: 1px solid #ddd;
padding: 15px; margin: 15px;}
pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}
</style>
</head>
<body>
<h1>Error: 500 Internal Server Error</h1>
<p>Sorry, the requested URL <tt>'http://127.0.0.1:8080/'</tt>
caused an error:</p>
<pre>Template 'foo' not found.</pre>
</body>
</html>
Note that the error message contains the missing template name:
Template 'foo' not found.

iPhone Browsers - Unable to download image

<!DOCTYPE html>
<!--
This page is shown when the extension button is clicked, because the
"browser_action" field in manifest.json contains the "default_popup" key with
value "popup.html".
-->
<html>
<head>
<title>Test title</title>
<style>
body {
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
font-size: 100%;
}
#status {
/* avoid an excessively wide status text */
white-space: pre;
text-overflow: ellipsis;
overflow: hidden;
max-width: 400px;
}
</style>
</head>
<body>
<p>Example 1<br>
<a href="http://dummyimage.com/600x400/000/fff.png" download>Download this image</a></p>
</body>
</html>
The above, is a button (kind of) that downloads an image. It works fine on my laptop, but when I navigate to the url on my iPhone it doesn't download. Just takes me to the actual image.
Anyone know why? Or how I can fix this?
Thanks!
iPhone doesn't have a download functionality. You will need to tap-and-hold, and select "Save".

Angular dart: Route links in Safari on iOS 7 stop working

I have been tearing my hair out over this for over a week now...
TL;DR: hash based links stop working in Safari on iOS 7 after a certain number of clicks.
We had a strange issue in our Angular Dart application - people using iPhones reported that links were "freezing" after "a while". The typical non helpful error reports, so we had to work hard to figure out exactly how to replicate the issue.
It eventually became clear that after the same number of clicks each time, Safari on iOS 7 would just stop navigating to the hash based route links.
After much diagnosis (removing bits of the app piece by piece until the issue stopped happening), I've managed to narrow it down to routes which contain parameters. After these routes are followed a certain number of times, Safari on iOS 7 just stops following them - it's like they get "half" clicked - the link gets underlined, but it is never followed, and subsequently no amount of clicking on it will allow it to be followed.
Here is a very simple dart application that will replicate the issue:
In the root folder:
pubspec.yaml:
name: DartRouteChecker
description: A sample web application
dependencies:
angular: 0.14.0
browser: any
transformers:
- angular
Then in the web folder:
dartroutechecker.dart:
library dart_route_checker;
import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';
class MyAppModule extends Module {
MyAppModule() {
bind(NgRoutingUsePushState, toValue: new NgRoutingUsePushState.value(false));
bind(RouteInitializerFn, toImplementation: Routes);
}
}
void main() {
applicationFactory()
.addModule(new MyAppModule())
.run();
}
#Injectable()
class Routes
{
void call(Router router, RouteViewFactory views) {
views.configure({
'route1': ngRoute(path: '/route1', defaultRoute: true, view: 'route1.html'),
'route2': ngRoute(path: '/route2/:id', view: 'route2.html')
});
}
}
dartroutechecker.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>DartRouteChecker</title>
<script async type="application/dart" src="dartroutechecker.dart"></script>
<script async src="packages/browser/dart.js"></script>
<link rel="stylesheet" href="dartroutechecker.css">
</head>
<body>
<ng-view></ng-view>
</body>
</html>
dartroutechecker.css
body {
background-color: #F8F8F8;
font-family: 'Open Sans', sans-serif;
font-size: 14px;
font-weight: normal;
line-height: 1.2em;
margin: 15px;
}
h1, p {
color: #333;
}
#sample_container_id {
width: 100%;
height: 400px;
position: relative;
border: 1px solid #ccc;
background-color: #fff;
}
#sample_text_id {
font-size: 24pt;
text-align: center;
margin-top: 140px;
-webkit-user-select: none;
user-select: none;
}
route1.html:
<h1>ROUTE 1</h1>
<div>
Go to second route
</div>
route2.html:
<h1>ROUTE 2</h1>
<div>
Go to first route
</div>
Use pub build to build the app (generate javascript), then navigate to it using an iPhone with iOS 7 (I tested it on an iPhone 5 and an iPhone 4S both with iOS 7.1.2). Click on "Go to second route" then "Go to first route" over and over again until you get to around 30 clicks - the link will then stop responding... It's almost always exactly 30 clicks that will cause it (though I have once or twice seen it be around 43, though I can't be sure I didn't click something else during those times - I've done so much stinkin' clickin' in the last week that I feel I'm going slightly insane...)
I can't replicate this issue when the iPhone is plugged in to a mac to debug it. It also doesn't happen if neither of the routes contains a parameter. And it happens with FEWER clicks if there are more routes defined in the route initialisation class, or if the routes contain multiple parameters. Initially I thought that the problem might have been that one of our routes had an ampersand in it, but that didn't turn out to be the case. And it doesn't happen at all in any other browsers, including Chrome on iOS.
I suspect this might be a bug in Safari (possibly related to Safari not handling hashchanges correctly, and not handling browser history correctly when using appcache (which, BTW, I am not using here)), but this is a real showstopper for us here - many of our customers are using iPhones, so if our app keeps freezing on the standard browser on an iPhone, we're in a lot of strife.
Has anyone seen anything like this before? Anyone have any suggestions for a workaround? Or a new career?.....
EDIT:
We have tracked the issue down to the route method in route.dart:
https://github.com/angular/route.dart/blob/master/lib/client.dart#L480
In the method gotoUrl (https://github.com/angular/route.dart/blob/master/lib/client.dart#L782), if we change it from route(url).then((success) { to new Future.value(true).then((success) { then the issue no longer occurs - of course then we lose all the "preenter" etc etc functionality that routing provides. But it seems that somewhere in that route function, something is going awry...
According to this issue linked in the comments by Günter, this has been fixed in 0.5.0 by this commit.
I can't understand what part of that commit fixes it from reading the code; so hopefully 0.5 is a relatively compatible version to upgrade to!

Resources