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

Sometimes returns the href of the search query as a result #20

Open
Themis3000 opened this issue Oct 28, 2021 · 3 comments
Open

Sometimes returns the href of the search query as a result #20

Themis3000 opened this issue Oct 28, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@Themis3000
Copy link

the following bit of code prints out the search query as a result for me:

from googlesearch import search

se = search("Google",num_results=10,lang="en")

print(se[-1])

here's what the output of the script looks like : /search?q=Google&num=11&hl=en&tbm=isch&source=iu&ictx=1&fir=mM5eejaz-bUIsM%252C0UCf55-GTy6fDM%252C%252Fm%252F045c7b&vet=1&usg=AI4_-kS3fhB6I4-4YGkbI-0POxk60cjoEw&sa=X&ved=2ahUKEwi8y-PKyuzzAhVRZc0KHSjABlkQ_B16BAhIEAI#imgrc=mM5eejaz-bUIsM

It seems like this is happening because of the descriptive result with more information that comes up on the right side. The package tries to process it like any other result and ends up selecting an element with no href value and tried to get the href value. The default action of BeautifulSoup is just to return the pages href value it seems and so that's how it end up at the back of the results.

@Themis3000
Copy link
Author

upon reviewing the code, it looks like this issue would be solved with pull request #3 due to it validating that it's returning links before returning them.

@Nv7-GitHub
Copy link
Owner

interesting, when I make my update I'll make sure to do that

tomviner pushed a commit to tomviner/googlesearch that referenced this issue Apr 2, 2023
@Nv7-GitHub
Copy link
Owner

Is this fixed?

@Nv7-GitHub Nv7-GitHub added the bug Something isn't working label Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants