Skip to content

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

Open
@Themis3000

Description

@Themis3000

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions