gautamkrishnar / socli

Stack overflow command line client. Search and browse stack overflow without leaving the terminal :computer:
https://pypi.python.org/pypi/socli
BSD 3-Clause "New" or "Revised" License
1.1k stars 218 forks source link

the search is broken for me #265

Closed simone-viozzi closed 3 years ago

simone-viozzi commented 3 years ago

πŸ› Bug Report

i just installed this package from AUR and every query reported an error. the AUR package is version 6.0 so i updated with pip install --upgrade socli and now i have the 6.3 version, but the search is still broken, every query i get the following error:

❯ socli for loop in python syntax
Traceback (most recent call last):
  File "/home/simone/.local/lib/python3.9/site-packages/socli/socli.py", line 107, in socli
    questions = search.get_questions_for_query_google(query)
  File "/home/simone/.local/lib/python3.9/site-packages/socli/search.py", line 87, in get_questions_for_query_google
    question_desc = result.find("div", recursive=False).find_all("div", recursive=False)[1] \
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/simone/.local/bin/socli", line 5, in <module>
    from socli.sentry import main
  File "/home/simone/.local/lib/python3.9/site-packages/socli/sentry.py", line 12, in <module>
    main()
  File "/home/simone/.local/lib/python3.9/site-packages/socli/socli.py", line 465, in main
    socli(query, json_output=json_output)
  File "/home/simone/.local/lib/python3.9/site-packages/socli/socli.py", line 116, in socli
    if len(questions) > 1:
UnboundLocalError: local variable 'questions' referenced before assignment
Sentry is attempting to send 1 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

i don't know if it's just me and i installed it wrongly or something else. i will follow the discussion and provide any information needed.

Have you read the Contributing Guidelines on Pull Requests?

yes.

welcome[bot] commented 3 years ago

Hello there!πŸ‘‹ Welcome to the project!πŸš€βš‘

Thank you and congratsπŸŽ‰ for opening your issue in this project. Please make sure that you follow our Code of ConductπŸ™Œ while interacting with the project. Have a good day!

gautamkrishnar commented 3 years ago

@simone-viozzi will take a look at it, thanks for reporting

gautamkrishnar commented 3 years ago

@simone-viozzi this issue was fixed on https://github.com/gautamkrishnar/socli/releases/tag/6.9 please upgrade the version

simone-viozzi commented 3 years ago

i need to do additional things after updating?

❯ pip install --upgrade socli
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: socli in ./.local/lib/python3.9/site-packages (6.3)
Collecting socli
  Downloading socli-6.9-py3-none-any.whl (34 kB)
Requirement already satisfied: sentry-sdk in ./.local/lib/python3.9/site-packages (from socli) (1.0.0)
Requirement already satisfied: requests in /usr/lib/python3.9/site-packages (from socli) (2.25.1)
Requirement already satisfied: argcomplete in /usr/lib/python3.9/site-packages (from socli) (1.12.1)
Requirement already satisfied: urwid in ./.local/lib/python3.9/site-packages (from socli) (2.1.2)
Requirement already satisfied: colorama in /usr/lib/python3.9/site-packages (from socli) (0.4.4)
Requirement already satisfied: BeautifulSoup4 in /usr/lib/python3.9/site-packages (from socli) (4.9.3)
Requirement already satisfied: Py-stackExchange in ./.local/lib/python3.9/site-packages (from socli) (2.2.7)
Requirement already satisfied: soupsieve>1.2 in /usr/lib/python3.9/site-packages (from BeautifulSoup4->socli) (2.2.1)
Requirement already satisfied: six>=1.8.0 in /usr/lib/python3.9/site-packages (from Py-stackExchange->socli) (1.15.0)
Requirement already satisfied: chardet>=3.0.2 in /usr/lib/python3.9/site-packages (from requests->socli) (4.0.0)
Requirement already satisfied: idna>=2.5 in /usr/lib/python3.9/site-packages (from requests->socli) (3.1)
Requirement already satisfied: urllib3>=1.21.1 in /usr/lib/python3.9/site-packages (from requests->socli) (1.26.4)
Requirement already satisfied: urllib3>=1.21.1 in /usr/lib/python3.9/site-packages (from requests->socli) (1.26.4)
Requirement already satisfied: certifi in ./.local/lib/python3.9/site-packages (from sentry-sdk->socli) (2020.12.5)
Installing collected packages: socli
  Attempting uninstall: socli
    Found existing installation: socli 6.3
    Uninstalling socli-6.3:
      Successfully uninstalled socli-6.3
Successfully installed socli-6.9

❯ socli for loop in python syntax
Traceback (most recent call last):
  File "/home/simone/.local/lib/python3.9/site-packages/socli/socli.py", line 107, in socli
    questions = search.get_questions_for_query_google(query)
  File "/home/simone/.local/lib/python3.9/site-packages/socli/search.py", line 87, in get_questions_for_query_google
    question_desc = result.find("div", recursive=False).find("div",recursive=False) \
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/simone/.local/bin/socli", line 5, in <module>
    from socli.sentry import main
  File "/home/simone/.local/lib/python3.9/site-packages/socli/sentry.py", line 12, in <module>
    main()
  File "/home/simone/.local/lib/python3.9/site-packages/socli/socli.py", line 465, in main
    socli(query, json_output=json_output)
  File "/home/simone/.local/lib/python3.9/site-packages/socli/socli.py", line 116, in socli
    if len(questions) > 1:
UnboundLocalError: local variable 'questions' referenced before assignment
Sentry is attempting to send 1 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

that's the output of the update and a search.

gautamkrishnar commented 3 years ago

@simone-viozzi, Yea looks like google is randomizing the structure. I am trying out various stuff to fix this. Thats why i reopened this one.

simone-viozzi commented 3 years ago

oh sorry, i missed that. thanks for the tempestive response.

gautamkrishnar commented 3 years ago

no problem πŸ˜„

kingpitka commented 3 years ago

Socli version 6.9

I ran into this problem over on "howdoi", the issue may very well be that Simone is in Europe since I'm getting a similar error message. Google checks for location and then returns this confirmation message before you can use the search function. I hope that somebody somewhere has properly solved this European googling issue :)

Also, and possibly unrelated, when routed through an American VPN I receive this error:

>socli for loops in python
←[33mNo results found...←[0m

image

simone-viozzi commented 3 years ago

yes, i'm from europe

gautamkrishnar commented 3 years ago

Hi Guys this is fixed. Please upgrade to latest version and try again(7.0). Thanks a lot for your comments.