PatNeedham/google-it

Orther Language (like vietnamese)

Closed this issue · 1 comments

can't change language

Hi @BerVerCoder thank you for bringing this up. Someone else coincidentally reported this issue within the past month (here) and mentioned that there is an lr query parameter that can be used to alter the language of returned search results.

I was able to confirm this by searching using this url: https://www.google.com/search?q=garmin&lr=lang_vi - not all the results are in Vietnamese, but the majority of them are. Unfortunately that extra query parameter cannot be included in google-it when running it from the command line. I was only able to confirm it working programmatically by passing an options argument that included some of the default values inside of it like this:

googleIt({
    query: 'garmin',
    options: {
        url: 'https://www.google.com/search',
        qs: {
          q: 'garmin',
          num: 10,
          start: 0,
          lr: 'lang_vi'
        },
        headers: {
          'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:34.0) Gecko/20100101 Firefox/34.0',
        },
    }
}).then(console.dir).catch(console.error);

The result of running that can be seen here (using RunKit):

image

Although I don't want to make it necessary to duplicate all the original options within the qs object (q, num, start) and within headers. Running it from a Node program should be as simple as:

googleIt({ query: 'garmin', language: 'vi' });

And from the command line:

google-it --query="garmin" --language="vi"

That is what I'll attempt to have available by end of today or tomorrow at the latest. Please let me know if anything else should be taken into consideration. But regardless, thank you again for prompting me to look more deeply into this!