PatNeedham / google-it

command line Google search and save to JSON
105 stars 35 forks source link

Google adverts to be displayed in the search result #61

Open basicserge opened 3 years ago

basicserge commented 3 years ago

Hi, thanks for a great tool! I found the search result doesn't include google ads. For me it is an important thing. Is it possible to add such an option?

PatNeedham commented 3 years ago

I think it would be possible to add that option. Are you looking for the ads that appear like regular search results, or the more product-specific ads that appear in a search like "lawn mower home depo", in their own separate section:

image

For the first kind, this query selector seems to be collecting the ad links, both in a logged-in chrome window as well as incognito: #tads > div > div > div > div.d5oMvf > a - can you confirm that does for you as well? I'm thinking the getResults function can be modified to accept an includeAds argument so that it can perform 3 similar query selectors for the ad-result titles links and snippets.

But it might not be that simple. Another search I tried just now is "chicago hotel" in incognito, and on the 2nd page, four ad results appeared above the organic ones, while another three appeared at the bottom of the page, which weren't counted as part of the #tads > div > div > div > div.d5oMvf > a selector.

basicserge commented 3 years ago

Thanks for the quick reply!

Yes, I'm looking for the first type, the regular search like results. I do confirm: my concern matches the selector #tads > div > div > div > div.d5oMvf > a, as well as the similar to #tads the #bottomads container at the bottom.

Seems the alternative query for both upper and bottom ads may looks like div[data-text-ad="1"] > div > div > a.

But I'm not sure it will work as I don't find those selectors when the JS is turned out.

The only thing I need actually is that those ads are in the same list as the regular search results.