urllib.request.urlopen fails with https
Irv Kalb
Irv at furrypants.com
Thu Mar 15 11:43:55 EDT 2018
On Mar 14, 2018, at 9:54 PM, Gregory Ewing <greg.ewing at canterbury.ac.nz> wrote:
>
> Chris Angelico wrote:
>> That means going back to the original problem: "how do we get a usable
>> stock price API?".
>
> Does it have to be stock prices in particular?
> Or just some simple piece of data that demonstrates
> the principles of fetching a url and parsing the
> result?
>
> --
> Greg
> --
I am the OP. No, it does not have to be stock prices. I used stock prices because it made for a very clear example in my curriculum. In my class, I demo how we can write a small Python program to "pretend to be a browser" and get a full page of html, then I talk about how you can use an API with a small Python program to get just the data you really want. I found a Yahoo API that did exactly what I wanted, and that has worked for years - but now Yahoo has cancelled that service. I thought it would be simple to find another simple API to get a stock price but I haven't found one. All the ones that do work seem to require https, which doesn't work easily with url lib.request.urlopen.
I do use other API's like openweathermap.org to get weather data and api.fixer.io <http://api.fixer.io/> to get currency exchange rates. I get the data back and work through parsing the results.
I am still very interested in getting a stock quote example but If you have other examples that have a URL that is http based, I am interested.
Irv
More information about the Python-list
mailing list