256 Kilobytes

Answers in Web Scraping, Data Analysis | By August R. Garcia

Published 3 weeks agoFri, 20 Sep 2019 10:59:05 -0700

135 views, 0 RAMs, and 1 comment

Tags: Google Sheets, Bing, Search Engines, IMPORTXML

Profile Photo - August R. Garcia August R. Garcia LARPing as a Sysadmi... Portland, OR
🗎 191 🗨 943 🐏 286
Site Owner

Used to have a solution to do this for Google search results via Google Sheets, but since the IP addresses that Google Sheets uses to make HTTP requests now seem to be either explicitly blacklisted or have been used to scrape Google so much by others that they're now hitting "please do a reCaptcha" errors, that solution is dead.

Anyway, you can do this for Bing where A1 contains some keyword you want to scrape:

=importXML("https://www.bing.com/search?q="&ENCODEURL(A1), "//*[@class='sb_count']")

It seems like there are some queries where Bing doesn't list the number of results at all, which throw an error, but other than that, this seems to work consistently.

Download more RAM. 🐏 ⨉ 0 Posted by August R. Garcia 3 weeks ago 🕓 Posted at 20 September, 2019 10:59 AM PDT

Sir, I can do you a nice SEO.

Profile Photo - August R. Garcia August R. Garcia LARPing as a Sysadmi... Portland, OR
🗎 191 🗨 943 🐏 286
Site Owner

Here's a better version that removes the " results" string and then casts the result to a number instead of a string:

=VALUE(substitute(importXML("https://www.bing.com/search?q="&ENCODEURL(B2), "//*[@class='sb_count']"), " results", ""))

Another wrapper function that replaces any "N/A" error messages (from results that don't show a result count) with a blank cell instead of an error:

=IFNA(VALUE(substitute(importXML("https://www.bing.com/search?q="&ENCODEURL(B2), "//*[@class='sb_count']"), " results", "")), "")
Download more RAM. 🐏 ⨉ 0 Posted by August R. Garcia 1 week ago

Edit History

• [2019-10-08 9:17 PDT] August R. Garcia (1 week ago)
• [2019-10-08 9:17 PDT] August R. Garcia (1 week ago)
• [2019-10-08 9:17 PDT] August R. Garcia (1 week ago)
🕓 Posted at 08 October, 2019 09:17 AM PDT

Sir, I can do you a nice SEO.

Post a New Comment

To leave a comment, login to your account or create an account.

Do you like having a good time?

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account
You can also login to an existing account or recover your password. All use of this site is subject to terms outlined in the terms of service and privacy policy.