googlesearch
googlesearch copied to clipboard
a search gives no result, no error, nothing
- google-search version: from pypi. There is no
googlesearch.__version__
, but install saysgoogle-search-1.1.1
- Python version: 3.8.5
- Operating System: Ubuntu 20.04
Description
Simple search. I get no results, no errors, and nothing.
What I Did
sander@brixit:~$ python3 -m pip install google-search
Collecting google-search
Downloading google_search-1.1.1-py2.py3-none-any.whl (6.5 kB)
Requirement already satisfied: soupsieve in ./.local/lib/python3.8/site-packages (from google-search) (2.2.1)
Requirement already satisfied: lxml in ./.local/lib/python3.8/site-packages (from google-search) (4.6.2)
Requirement already satisfied: beautifulsoup4 in ./.local/lib/python3.8/site-packages (from google-search) (4.9.3)
Installing collected packages: google-search
Successfully installed google-search-1.1.1
sander@brixit:~$ python3
Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from googlesearch.googlesearch import GoogleSearch
>>> response = GoogleSearch().search("something")
>>> response.results
[]
>>>
Other machine same same:
>>> from googlesearch.googlesearch import GoogleSearch
>>> response = GoogleSearch().search("something")
>>> print(response.results)
[]
>>> response.
response.results response.total
>>> response.total
4
>>>
Am I doing something wrong?
I get the same problem
Same here. Can anyone help me?
I think it's because the selector is not working So we can just wait until it gets fixed
Same here
I fixed the problem, by change RESULT_SELECTOR = "div.g"
to RESULT_SELECTOR = "div.g>div>div"
(Update!) NEW SOLUTION HERE: https://github.com/anthonyhseb/googlesearch/issues/75#issuecomment-876229778
https://github.com/anthonyhseb/googlesearch/blob/e2d3e74a89151bdbe6529400291f72369aa1bcc5/googlesearch/googlesearch.py#L24
and then, replace code line 70 with selector = GoogleSearch.RESULT_SELECTOR
or just delete it and change soup.select()
argument (line 71) with self.RESULT_SELECTOR
https://github.com/anthonyhseb/googlesearch/blob/e2d3e74a89151bdbe6529400291f72369aa1bcc5/googlesearch/googlesearch.py#L70-L71
Here my output
self.RESULT_SELECTOR
KeyError: 'href' when trying your fix
@BisratGetnet I have new solution here
Change RESULT_SELECTOR
to:
RESULT_SELECTOR = "div.g>div>div.tF2Cxc"
Here my output, for my new solution
it's remove duplicate result (you can compare with my previous screenshot)
@BisratGetnet I have new solution here
Change
RESULT_SELECTOR
to:RESULT_SELECTOR = "div.g>div>div.tF2Cxc"
Here my output, for my new solution
it's remove duplicate result (you can compare with my previous screenshot)
Thanks for replaying but still same error i think it's because google user different selector in different countries can you show me how to take a selector based on google search results.
Thanks for replaying but still same error i think it's because google user different selector in different countries can you show me how to take a selector based on google search results.
Ah... okay.
You need to open Inspect on your browser, and then select element that you want to scrape, after that right click element and then copy Selector/CSS Selector. Alternatively you can find element manually.
To test whether the element being searched for is correct, you can test using method querySelectorAll or querySelector on your Console.
for example:
document.querySelectorAll('div.g>div>div.tF2Cxc');
Here's reference for CSS Selector: https://www.w3schools.com/cssref/css_selectors.asp
Sorry if my explanation is not detailed enough or makes you confused because of my English 🙈, hope it helps you.
I only got "HTTPError: Too Many Requests", anyone can help?
just use 'googlesearch' liberary by author = 'Anime no Sekai' copyright = 'Copyright 2021, googlesearch' credits = ['animenosekai'] license = 'MIT License' version = 'googlesearch v1.1.1' maintainer = 'Anime no Sekai' email = '[email protected]' status = 'Stable'
it works fine for me