Skip to content

basic search does not work at all #155

Open
@braindevices

Description

@braindevices

Describe the bug

ENGINE FAILURE: Bing
raise NoResultsOrTrafficError(
search_engine_parser.core.exceptions.NoResultsOrTrafficError: The result parsing was unsuccessful. It is either your query could not be found or it was flagged as unusual traffic

I tried the example from readme page. gsearch and bsearch all raise the same error.

the ysearch throw a different error:

line 61, in parse_single_result
    rdict["descriptions"] = desc.text
AttributeError: 'NoneType' object has no attribute 'text'

Activity

braindevices

braindevices commented on Jan 25, 2022

@braindevices
Author

my ip is not blocked by any of those search engines. I try to debug a little bit by output the url and html with following code:

from search_engine_parser.core.engines.google import Search as GoogleSearch

gsearch = GoogleSearch()
search_args = ('python google search api', 1)
gsearch.search(*search_args, cache=False, hl="en")

The url is https://www.google.com/search?start=0&q=python+google+search+api&gbv=1&hl=en
And I found the resulting html from get_source() saying:

Before you continue to Google Search
Google uses cookies and data to:

    Deliver and maintain services, like tracking outages and protecting against spam, fraud, and abuse
    Measure audience engagement and site statistics to understand how our services are used

If you agree, we’ll also use cookies and data to:

    Improve the quality of our services and develop new ones
    Deliver and measure the effectiveness of ads
    Show personalized content, depending on your settings
    Show personalized or generic ads, depending on your settings, on Google and across the web

For non-personalized content and ads, what you see may be influenced by things like the content you’re currently viewing and your location (ad serving is based on general location). Personalized content and ads can be based on those things and your activity like Google searches and videos you watch on YouTube. Personalized content and ads include things like more relevant results and recommendations, a customized YouTube homepage, and ads that are tailored to your interests.

Click “Customize” to review options, including controls to reject the use of cookies for personalization and information about browser-level controls to reject some or all cookies for other uses. You can also visit g.co/privacytools anytime.

So it seems like you need to confirm something and save some cookie before you could go on.

braindevices

braindevices commented on Jan 25, 2022

@braindevices
Author

bingsearch only works once per 5 to 8 trials. no idea why though.

neithere

neithere commented on Aug 26, 2022

@neithere
Contributor

Looks like the consent cookie should be set, e.g. like this: https://stackoverflow.com/a/70560365/68097

Unfortunately the lib doesn't seem to be configurable in this aspect. The cookies argument should be passed to aiohttp.ClientSession() in CacheHandler.get_source(): https://github.com/bisohns/search-engine-parser/blob/master/search_engine_parser/core/utils.py#L78

FYI, I've added a very crude workaround here: a537f4e
Obviously a proper implementation should add an engine-dependent set of default cookies or something in this vein.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @neithere@braindevices

        Issue actions

          basic search does not work at all · Issue #155 · bisohns/search-engine-parser