Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INDEX OUT OF RANGE #187

Open
josyjr25 opened this issue Aug 27, 2023 · 1 comment
Open

INDEX OUT OF RANGE #187

josyjr25 opened this issue Aug 27, 2023 · 1 comment

Comments

@josyjr25
Copy link

Can anyone help me with these errors:

IndexError Traceback (most recent call last)
Cell In[1], line 20
9 filters = Screener.load_filter_dict()
11 filters = [
12 "cap_small",
13 "fa_sales5years_pos",
(...)
18 "ta_volatility_mo3&ft=4&o=ticker"
19 ]
---> 20 stock_list = Screener(filters=filters, table="Performance")
22 print(stock_list)
25 # Monthly, Candles, Large, No Technical Analysis

File ~\anaconda3\lib\site-packages\finviz\screener.py:128, in Screener.init(self, tickers, filters, rows, order, signal, table, custom, user_agent, request_method)
125 self._request_method = request_method
127 self.analysis = []
--> 128 self.data = self.__search_screener()

File ~\anaconda3\lib\site-packages\finviz\screener.py:436, in Screener.__search_screener(self)
421 """ Private function used to return data from the FinViz screener. """
423 self._page_content, self._url = http_request_get(
424 "https://finviz.com/screener.ashx",
425 payload={
(...)
433 user_agent=self._user_agent,
434 )
--> 436 self._rows = self.__check_rows()
437 self.headers = self.__get_table_headers()
439 if self._request_method == "async":

File ~\anaconda3\lib\site-packages\finviz\screener.py:404, in Screener.__check_rows(self)
398 def __check_rows(self):
399 """
400 Checks if the user input for row number is correct.
401 Otherwise, modifies the number or raises NoResults error.
402 """
--> 404 self._total_rows = scrape.get_total_rows(self._page_content)
406 if self._total_rows == 0:
407 raise NoResults(self._url.split("?")[1])

File ~\anaconda3\lib\site-packages\finviz\helper_functions\scraper_functions.py:46, in get_total_rows(page_content)
42 """ Returns the total number of rows(results). """
44 total_element = page_content.cssselect('td[width="128"]')
45 total_number = (
---> 46 etree.tostring(total_element[0]).decode("utf-8").split("")[1].split()[0]
47 )
49 try:
50 return int(total_number)

IndexError: list index out of range

@AGG2017
Copy link

AGG2017 commented Aug 28, 2023

Read the suggestions from #182.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants