JECSand / yahoofinancials

A powerful financial data module used for pulling data from Yahoo Finance. This module can pull fundamental and technical data for stocks, indexes, currencies, cryptos, ETFs, Mutual Funds, U.S. Treasuries, and commodity futures.
https://pypi.python.org/pypi/yahoofinancials
MIT License
899 stars 214 forks source link

UrlOpener style of invoking requests is deprecated #40

Closed rsheftel closed 1 year ago

rsheftel commented 4 years ago

I get the following warning when using this package:

DeprecationWarning: UrlOpener style of invoking requests is deprecated. Use newer urlopen functions/methods

JECSand commented 4 years ago

@rsheftel

Thank you for bringing this up. I have been trying to find a way to do this with urlopen for awhile now. The requests are rejected for some reason. If you could find a way to get it working and open a merge request it would help a ton. I am really busy right now on other projects. I probably wouldn't be able to look at this until the beginning of next year.

rsheftel commented 4 years ago

I will take a look, I am not well versed in these packages so not sure I will succeed.

JECSand commented 4 years ago

I will take a look, I am not well versed in these packages so not sure I will succeed.

Thanks!

edit:

Just wanted to add that this maybe a good place for you to start looking:

https://stackoverflow.com/questions/54261450/trying-to-use-fancyurlopener-in-python3-for-a-pdf-but-it-gives-me-a-deprecation

alecjonas commented 4 years ago

Was a solution ever found for this?

alecjonas commented 4 years ago

I fixed the init file: Have to add this at the top: from urllib.request import urlopen In the code, change to this: response = urlopen(url) and response = urlopen(api_url)

FrankDMartinez commented 4 years ago

@alecjonas When I do that for Python 3.8, I receive the following warnings:

/usr/local/lib/python3.8/site-packages/yahoofinancials/init.py:153 /usr/local/lib/python3.8/site-packages/yahoofinancials/init.py:153: DeprecationWarning: invalid escape sequence \s self._cache[url] = loads(re.search("root.App.main\s+=\s+({.*})", script).group(1))

/usr/local/lib/python3.8/site-packages/html5lib/_trie/_base.py:3 /usr/local/lib/python3.8/site-packages/html5lib/_trie/_base.py:3: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working from collections import Mapping

-- Docs: https://docs.pytest.org/en/latest/warnings.html

@JECSand A friendly FYI

It otherwise works.

Wittionary commented 3 years ago

I came across this repo/issue while troubleshooting the same warning on my app. I nixed the warning by switching from urllib to requests altogether. It was a really painless transition.

@JECSand Are you open to the idea of switching the library?

JECSand commented 1 year ago

@Wittionary I'm not against the idea, the initial goal was to try keeping 3rd party requirements to a minimum.