Coder Social home page Coder Social logo

Comments (4)

shashank7596 avatar shashank7596 commented on September 1, 2024

@tsukuuyomi

I had the same issue too and I only know the reason for the issue. Looking forward for the solution.

Reason for that is there's no package called urllib2 in python-3 version. It's only in python-2. Instead there's an equivalent which is urllib.request for it. I think the author should modify that in order to make it compatible for newer python version.

Please anyone help us in getting this issue resolved.

from googlesearch.

Viole-Grace avatar Viole-Grace commented on September 1, 2024

@shashank7596 just importing it as import urllib.request as urllib2 does not work either. :/
It gives me a weird 'list index out of range' error, presumably from the urllib.request.quote()
I am unsure of what causes the error, but just fixing the import does not seem to solve the issue.
I think there are a few changes I am missing.

from googlesearch.

 avatar commented on September 1, 2024

this is still a problem it seems, tried the example on the module README

>>> from googlesearch.googlesearch import GoogleSearch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<HIDDENPATH>/site-packages/googlesearch/googlesearch.py", line 6, in <module>
    import urllib2
ModuleNotFoundError: No module named 'urllib2'
>>> response = GoogleSearch().search("something")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'GoogleSearch' is not defined
>>> for result in response.results:
...     print("Title: " + result.title)
...     print("Content: " + result.getText())
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'response' is not defined

from googlesearch.

Alicia426 avatar Alicia426 commented on September 1, 2024

I am having the same issue, I peeked and found this line was the culprit.

totalText = soup.select(GoogleSearch.TOTAL_SELECTOR)[0].children.next().encode('utf-8')

Printing the soup object returns and empty list.
print(soup.select(GoogleSearch.TOTAL_SELECTOR)) # outputs []

I will dig more into it.

from googlesearch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.