lit26 / finvizfinance

Finviz analysis python library.

Home Page:https://finvizfinance.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BUG: Screen Does't work !!!!

mmgarcia opened this issue · comments

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

from finvizfinance.screener.overview import Overview
foverview = Overview()
filters_dict = {'Index': 'S&P 500', 'Sector': 'Basic Materials'}
foverview.set_filter(filters_dict=filters_dict)
df = foverview.screener_view()
df.head()


Error
cgptenv/lib/python3.11/site-packages/finvizfinance/screener/overview.py", line 280, in screener_view
    rows = table.findAll("tr")
           ^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'findAll'

Issue Description

the error is because table with class name "table-light" does not exist on dark mode

table = soup.find("table", class_="table-light")

Expected Behavior

return a list of tickers

Installed Versions

Replace this line with the output of finvizfinance.version

finvizfinance-0.14.6

Hi @mmgarcia, I noticed that this error with "findAll" method is due to an BeautifulSoup update, they changed some methods.
for example: "findAll" became "find_all". You can check it here:
https://beautiful-soup-4.readthedocs.io/en/latest/index.html?highlight=find#id18
I tried to fix the Overview.py by changing these methods, so far I have not been successful.
I just sent an email to the developer, wish he can help us!
See you!

I will check beautiful soup lib.

I will check beautiful soup lib.

Thank you so much!
I downloaded via zip file and replaced the files in the folders and it worked fine.

@lit26 @Mauriciopc92 did you figure out how to fix this one? I'm not tracking on the fix yet .

I have the same issue with screeners, both the "Overview" screener and the "Ownership" screener I have tried so far with the same error that was described above. Seems like soup does not find a table with "table-light" class and can confirm it when I print out and search in the HTML result that comes from soup.

I'm running conda environment with python3.7, finvizfinance 0.14.6, and tried upgrading beautifulsoup4 from 4.11.1 to 4.12.2 version.

So the issue comes from the beautifulsoup lib. I am still working on that. You can downgrade that lib for now.

please let us know how it goes, really appreciate the effort!

@lit26 I tried to open a PR to suggest a fix for this one, but getting permission denied. Anyway, here's a screenshot of my diff to the "screener/overview.py" file, that seems to make this work for me:

image

@lit26 I tried to open a PR to suggest a fix for this one, but getting permission denied. Anyway, here's a screenshot of my diff to the "screener/overview.py" file, that seems to make this work for me:

image

PS I tried downgrading BS lib to a couple of the earlier 4 versions, but was still getting the same issue. It seems to not mind "findAll" vs. suggested new "find_all" syntax for whatever reason, but it's possible I could be overlooking something, too.

It seemed like the external finviz HTML might've changed that caused this issue, so just need to select the elements differently.