LuanRT / google-this

A simple yet powerful module to retrieve organic search results and much more from Google.

Home Page:https://www.npmjs.com/package/googlethis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question - How to pass advanced search operators?

sabatale opened this issue · comments

Question

Hey there, great library!

We understand you can use some parameters such as hl that are passed through ${Constants.URLS.GOOGLE}search?q=${_query}&ie=UTF-8&aomd=1${(safe ? '&safe=active' : '')}&start=${page}.

Does this also support advanced search operators? We're trying to use allinurl in the following way:

const options = {
  page: 0, 
  safe: false, // Safe Search
  parse_ads: false, // If set to true sponsored results will be parsed
  additional_params: { 
    // add additional parameters here, see https://moz.com/blog/the-ultimate-guide-to-the-google-search-parameters and https://www.seoquake.com/blog/google-search-param/
    allinurl: "%22https%3A%2F%2Fdummy.*.com%2F%22" // Tried decoded
  }
};

const response = await google.search('', options);

Assuming that would create ${Constants.URLS.GOOGLE}search?q=allinurl:"https://dummy.*.com/"&....

But it doesn't seem to work. Passing something like const response = await google.search('"https://dummy.*.com/"', { ...allinurl: true }) returns the results without the additional search operator.

Other details

Latest version.

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.

Nevermind. We had mistakenly understood allinurl as a parameter when it's just part of the query.

const response = await google.search('allinurl:"blahblah"', options);