256 Kilobytes

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

Published

621 views, 0 RAMs, and 1 comment

Tags: Google Sheets, Bing, Search Engines, IMPORTXML

Profile Photo - August R. GarciaAugust R. GarciaLARPing as a Sysadmi...Portland, ORSite 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. 🐏 ⨉ 0Posted by August R. Garcia 1 year ago 🕓 Posted at 20 September, 2019 10:59 AM PDT

Sir, I can do you a nice SEO.

Profile Photo - August R. GarciaAugust R. GarciaLARPing as a Sysadmi...Portland, ORSite 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. 🐏 ⨉ 0Posted by August R. Garcia 1 year ago

Edit History

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

Sir, I can do you a nice SEO.

Post a New Comment

Do you like having a good time?

Register an Account

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

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

Answers— Read More

Find more related content below!