How to Scrape Yellow Pages: Business Names, Addresses, Phone Numbers (Code & No Code)

2022-09-29 - 4 min read

Nicolae Rotaru
Nicolae Rotaru


Yellow Pages is a online directory that helps you connect instantly with great local businesses.
You can find over 20 million business listings, browse menus, search by cuisine, book a table, see showtimes, find cheap gas, and navigate with maps.

In this article, you will read about the easiest way to scrape Yellow Pages data with Page2API.

You will find code examples for Ruby, Python, PHP, NodeJS, cURL, and a No-Code solution that will import Yellow Pages data into Google Sheets.

You can scrape data from Yellow Pages, that will contain such information as business names, phone numbers, addresses, ratings, and more.

In this article, we will learn how to:

  • Scrape Yellow Pages data
  • Export Yellow Pages data to Google Sheets


To start scraping Yellow Pages, you will need the following things:

  • A Page2API account
  • A category and a location, in which we want to search for listings. Let's search for 'Restaurants, Miami'.

How to scrape Yellow Pages data

First, we need to open the Yellow Pages search page and set the filters we need.

This will change the URL to something similar to:

The page we see must look similar to the following one:

Yellow Pages listings page

From the search page, we will scrape the following attributes:

  • Title
  • URL
  • Website
  • Phone
  • Street
  • Locality
  • Categories
  • Snippet
  • Internal rating
  • Internal rating count
  • Tripadvisor rating
  • Tripadvisor rating count

Now, let's define the selectors for each attribute.

    /* Parent: */

    /* Title: */

    /* URL: */

    /* Website: */

    /* Phone: */

    /* Street: */

    /* Locality: */

    /* Categories: */
    .categories a

    /* Snippet: */

    /* Internal rating: */
    .rating .result-rating

    /* Internal rating count: */
    .rating .count

    /* Tripadvisor rating: */

    /* Tripadvisor rating count: */

In order to collect all the ratings - we must run the JS snippet below:

    /* convert tripadvisor rating value */

    document.querySelectorAll(".ta-rating").forEach(function(e) {
      let ta_rating = e.attributes.class.value.trim().split(/\s+/).reverse()[0].replace("ta-", "").replace("-", ".");
      e.dataset.ta_rating = ta_rating;

    /* convert tripadvisor rating count */

    document.querySelectorAll(".ta-count").forEach(function(e) {
      let ta_count = e.textContent.replace(/[\(\)]+/g, "");
      e.dataset.ta_count = ta_count;

    /* convert internal rating value */

    document.querySelectorAll(".rating .result-rating").forEach(function(e) {
      let internal_rating_word = e.attributes.class.value.replace("result-rating", "").trim().replace(" ", "-");
      let rating_mapping = {
        "one": 1, "one-half": 1.5, "two": 2, "two-half": 2.5, "three": 3, "three-half": 3.5, "four": 4, "four-half": 4.5, "five": 5
      e.dataset.internal_rating = rating_mapping[internal_rating_word];

    /* convert internal rating count */

    document.querySelectorAll(".rating .count").forEach(function(e) {
      let extra_count = e.textContent.replace(/[\(\)]+/g, "");
      e.dataset.internal_rating_count = extra_count;

Let's convert that snippet to base64:


Now, let's handle the pagination.

If we take a look at the URL structure when switching between pages, we see that they look like this:

    // Page 1

    // Page 2

    // Page 3

This looks like a great scenario to use the batch scraping approach.

Now let's build the request that will scrape all listings that the search page returned.

The following examples will show how to scrape 3 pages of listings from

The payload for our scraping request will be:

      "api_key": "YOUR_PAGE2API_KEY",
      "batch": {
        "urls": "[1, 3, 1]",
        "concurrency": 1,
        "merge_results": true
      "real_browser": true,
      "scenario": [
        { "wait": 5 },
        { "execute_js": "ICAgIC8qIGNvbnZlcnQgdHJpcGFkdmlzb3IgcmF0aW5nIHZhbHVlICovCgogICAgZG9jdW1lbnQucXVlcnlTZWxlY3RvckFsbCgiLnRhLXJhdGluZyIpLmZvckVhY2goZnVuY3Rpb24oZSkgewogICAgICBsZXQgdGFfcmF0aW5nID0gZS5hdHRyaWJ1dGVzLmNsYXNzLnZhbHVlLnRyaW0oKS5zcGxpdCgvXHMrLykucmV2ZXJzZSgpWzBdLnJlcGxhY2UoInRhLSIsICIiKS5yZXBsYWNlKCItIiwgIi4iKTsKICAgICAgZS5kYXRhc2V0LnRhX3JhdGluZyA9IHRhX3JhdGluZzsKICAgIH0pOwoKCiAgICAvKiBjb252ZXJ0IHRyaXBhZHZpc29yIHJhdGluZyBjb3VudCAqLwoKICAgIGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoIi50YS1jb3VudCIpLmZvckVhY2goZnVuY3Rpb24oZSkgewogICAgICBsZXQgdGFfY291bnQgPSBlLnRleHRDb250ZW50LnJlcGxhY2UoL1tcKFwpXSsvZywgIiIpOwogICAgICBlLmRhdGFzZXQudGFfY291bnQgPSB0YV9jb3VudDsKICAgIH0pOwogICAgCiAgICAvKiBjb252ZXJ0IGludGVybmFsIHJhdGluZyB2YWx1ZSAqLwoKICAgIGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoIi5yYXRpbmcgLnJlc3VsdC1yYXRpbmciKS5mb3JFYWNoKGZ1bmN0aW9uKGUpIHsKICAgICAgbGV0IGludGVybmFsX3JhdGluZ193b3JkID0gZS5hdHRyaWJ1dGVzLmNsYXNzLnZhbHVlLnJlcGxhY2UoInJlc3VsdC1yYXRpbmciLCAiIikudHJpbSgpLnJlcGxhY2UoIiAiLCAiLSIpOwogICAgICBsZXQgcmF0aW5nX21hcHBpbmcgPSB7CiAgICAgICAgIm9uZSI6IDEsICJvbmUtaGFsZiI6IDEuNSwgInR3byI6IDIsICJ0d28taGFsZiI6IDIuNSwgInRocmVlIjogMywgInRocmVlLWhhbGYiOiAzLjUsICJmb3VyIjogNCwgImZvdXItaGFsZiI6IDQuNSwgImZpdmUiOiA1CiAgICAgIH0KICAgICAgZS5kYXRhc2V0LmludGVybmFsX3JhdGluZyA9IHJhdGluZ19tYXBwaW5nW2ludGVybmFsX3JhdGluZ193b3JkXTsKICAgIH0pOwoKCiAgICAvKiBjb252ZXJ0IGludGVybmFsIHJhdGluZyBjb3VudCAqLwoKICAgIGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoIi5yYXRpbmcgLmNvdW50IikuZm9yRWFjaChmdW5jdGlvbihlKSB7CiAgICAgIGxldCBleHRyYV9jb3VudCA9IGUudGV4dENvbnRlbnQucmVwbGFjZSgvW1woXCldKy9nLCAiIik7CiAgICAgIGUuZGF0YXNldC5pbnRlcm5hbF9yYXRpbmdfY291bnQgPSBleHRyYV9jb3VudDsKICAgIH0pOw==" },
        { "execute": "parse" }
      "parse": {
        "listings": [
            "_parent": "div.result",
            "title": ".business-name >> text",
            "url": ".business-name >> href",
            "phone": ".phone >> text",
            "street": ".street-address >> text",
            "locality": ".locality >> text",
            "website": ".track-visit-website >> href",
            "categories": [".categories a >> text"],
            "snippet": ".snippet >> text",
            "internal_rating": ".rating .result-rating >> data-internal_rating",
            "internal_rating_count": ".rating .count >> data-internal_rating_count",
            "tripadvisor_rating": ".ta-rating >> data-ta_rating",
            "tripadvisor_rating_count": ".ta-count >> data-ta_count"

In case we don't need the ratings - the payload for our scraping request will be:

      "api_key": "YOUR_PAGE2API_KEY",
      "batch": {
        "urls": "[1, 3, 1]",
        "concurrency": 1,
        "merge_results": true
      "parse": {
        "listings": [
            "_parent": "div.result",
            "title": ".business-name >> text",
            "url": ".business-name >> href",
            "phone": ".phone >> text",
            "street": ".street-address >> text",
            "locality": ".locality >> text",
            "website": ".track-visit-website >> href",
            "categories": [".categories a >> text"],
            "snippet": ".snippet >> text"

Worth mentioning: due to the fact that the real browser is not being used - the payload above will run few times faster and consume less credits.

Code examples

    require 'rest_client'
    require 'json'

    api_url = ""
    payload = {
      api_key: "YOUR_PAGE2API_KEY",
      batch: {
        urls: "[1, 3, 1]",
        concurrency: 1,
        merge_results: true
      real_browser: true,
      scenario: [
        { wait: 5 },
        { execute_js: "ICAgIC8qIGNvbnZlcnQgdHJpcGFkdmlzb3IgcmF0aW5nIHZhbHVlICovCgogICAgZG9jdW1lbnQucXVlcnlTZWxlY3RvckFsbCgiLnRhLXJhdGluZyIpLmZvckVhY2goZnVuY3Rpb24oZSkgewogICAgICBsZXQgdGFfcmF0aW5nID0gZS5hdHRyaWJ1dGVzLmNsYXNzLnZhbHVlLnRyaW0oKS5zcGxpdCgvXHMrLykucmV2ZXJzZSgpWzBdLnJlcGxhY2UoInRhLSIsICIiKS5yZXBsYWNlKCItIiwgIi4iKTsKICAgICAgZS5kYXRhc2V0LnRhX3JhdGluZyA9IHRhX3JhdGluZzsKICAgIH0pOwoKCiAgICAvKiBjb252ZXJ0IHRyaXBhZHZpc29yIHJhd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LCAiIik7CiAgICAgIGUuZGF0YXNldC5pbnRlcm5hbF9yYXRpbmdfY291bnQgPSBleHRyYV9jb3VudDsKICAgIH0pOw==" },
        { execute: "parse" }
      parse: {
        listings: [
            _parent: "div.result",
            title: ".business-name >> text",
            url: ".business-name >> href",
            phone: ".phone >> text",
            street: ".street-address >> text",
            locality: ".locality >> text",
            website: ".track-visit-website >> href",
            categories: [".categories a >> text"],
            snippet: ".snippet >> text",
            internal_rating: ".rating .result-rating >> data-internal_rating",
            internal_rating_count: ".rating .count >> data-internal_rating_count",
            tripadvisor_rating: ".ta-rating >> data-ta_rating",
            tripadvisor_rating_count: ".ta-count >> data-ta_count"

    response = RestClient::Request.execute(
      method: :post,
      payload: payload.to_json,
      url: api_url,
      headers: { "Content-type" => "application/json" },

    result = JSON.parse(response)


The result

      "result": {
        "listings": [
            "title": "Don Camarón Seafood Grill & Market",
            "url": "",
            "phone": "(786) 688-3071",
            "street": "501 NW 37th Ave",
            "locality": "Miami, FL 33125",
            "website": "",
            "categories": [
              "Cuban Restaurants",
            "snippet": "I like to say when a please is great and this is one of the best. You go to fish market select your Pargo (Snapper) and they deep fry it to my…",
            "internal_rating": "3",
            "internal_rating_count": "5",
            "tripadvisor_rating": "4.0",
            "tripadvisor_rating_count": "157"
            "title": "Steve's Pizza",
            "url": "",
            "phone": "(305) 233-4561",
            "street": "18063 S Dixie Hwy",
            "locality": "Miami, FL 33157",
            "website": "",
            "categories": [
              "Take Out Restaurants"
            "snippet": "Great pizza! Love it! Will continue to go back",
            "internal_rating": "4.5",
            "internal_rating_count": "27",
            "tripadvisor_rating": "4.0",
            "tripadvisor_rating_count": "63"
      }, ...

How to export Yellow Pages data to Google Sheets

In order to be able to export our Yellow Pages listings to a Google Spreadsheet we will need to slightly modify our request to receive the data in CSV format instead of JSON.

According to the documentation, we need to add the following parameters to our payload:
    "raw": {
      "key": "listings", "format": "csv"

Now our payload will look like:

{ "api_key": "YOUR_PAGE2API_KEY", "batch": { "urls": [ "" ], "concurrency": 1, "merge_results": true }, "real_browser": true, "scenario": [ { "wait": 5 }, { "execute_js": "ICAgIC8qIGNvbnZlcnQgdHJpcGFkdmlzb3IgcmF0aW5nIHZhbHVlICovCgogICAgZG9jdW1lbnQucXVlcnlTZWxlY3RvckFsbCgiLnRhLXJhdGluZyIpLmZvckVhY2goZnVuY3Rpb24oZSkgewogICAgICBsZXQgdGFfcmF0aW5nID0gZS5hdHRyaWJ1dGVzLmNsYXNzLnZhbHVlLnRyaW0oKS5zcGxpdCgvXHMrLykucmV2ZXJzZSgpWzBdLnJlcGxhY2UoInRhLSIsICIiKS5yZXBsYWNlKCItIiwgIi4iKTsKICAgICAgZS5kYXRhc2V0LnRhX3JhdGluZyA9IHRhX3JhdGluZzsKICAgIH0pOwoKCiAgICAvKiBjb252ZXJ0IHRyaXBhZHZpc29yIHJhdGluZyBjb3VudCAqLwoKICAgIGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoIi50YS1jb3VudCIpLmZvckVhY2goZnVuY3Rpb24oZSkgewogICAgICBsZXQgdGFfY291bnQgPSBlLnRleHRDb250ZW50LnJlcGxhY2UoL1tcKFwpXSsvZywgIiIpOwogICAgICBlLmRhdGFzZXQudGFfY291bnQgPSB0YV9jb3VudDsKICAgIH0pOwogICAgCiAgICAvKiBjb252ZXJ0IGludGVybmFsIHJhdGluZyB2YWx1ZSAqLwoKICAgIGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoIi5yYXRpbmcgLnJlc3VsdC1yYXRpbmciKS5mb3JFYWNoKGZ1bmN0aW9uKGUpIHsKICAgICAgbGV0IGludGVybmFsX3JhdGluZ193b3JkID0gZS5hdHRyaWJ1dGVzLmNsYXNzLnZhbHVlLnJlcGxhY2UoInJlc3VsdC1yYXRpbmciLCAiIikudHJpbSgpLnJlcGxhY2UoIiAiLCAiLSIpOwogICAgICBsZXQgcmF0aW5nX21hcHBpbmcgPSB7CiAgICAgICAgIm9uZSI6IDEsICJvbmUtaGFsZiI6IDEuNSwgInR3byI6IDIsICJ0d28taGFsZiI6IDIuNSwgInRocmVlIjogMywgInRocmVlLWhhbGYiOiAzLjUsICJmb3VyIjogNCwgImZvdXItaGFsZiI6IDQuNSwgImZpdmUiOiA1CiAgICAgIH0KICAgICAgZS5kYXRhc2V0LmludGVybmFsX3JhdGluZyA9IHJhdGluZ19tYXBwaW5nW2ludGVybmFsX3JhdGluZ193b3JkXTsKICAgIH0pOwoKCiAgICAvKiBjb252ZXJ0IGludGVybmFsIHJhdGluZyBjb3VudCAqLwoKICAgIGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoIi5yYXRpbmcgLmNvdW50IikuZm9yRWFjaChmdW5jdGlvbihlKSB7CiAgICAgIGxldCBleHRyYV9jb3VudCA9IGUudGV4dENvbnRlbnQucmVwbGFjZSgvW1woXCldKy9nLCAiIik7CiAgICAgIGUuZGF0YXNldC5pbnRlcm5hbF9yYXRpbmdfY291bnQgPSBleHRyYV9jb3VudDsKICAgIH0pOw==" }, { "execute": "parse" } ], "parse": { "listings": [ { "_parent": "div.result", "title": ".business-name >> text", "phone": ".phone >> text", "street": ".street-address >> text", "locality": ".locality >> text", "website": ".track-visit-website >> href", "categories": [".categories a >> text"], "internal_rating": ".rating .result-rating >> data-internal_rating", "internal_rating_count": ".rating .count >> data-internal_rating_count", "tripadvisor_rating": ".ta-rating >> data-ta_rating", "tripadvisor_rating_count": ".ta-count >> data-ta_count", "snippet": ".snippet >> text", "details_url": ".business-name >> href" } ] }, "raw": { "key": "listings", "format": "csv" } }

Now, edit the payload above if needed, and press Encode →

The URL with encoded payload will be:

  Press 'Encode'

Note: If you are reading this article being logged in - you can copy the link above since it will already have your api_key in the encoded payload.

The final part is adding the IMPORTDATA function, and we are ready to import our Yellow Pages listings into a Google Spreadsheet.
  Press 'Encode'

The result must look like the following one:

Yellow Pages listings import to Google Sheets

Final thoughts

Scraping Yellow Pages manually can be a bit challenging and hard to scale.
However, a Web Scraping API can easily help you overcome this hassle and scrape the data in no time.
With Page2API you can quickly get access to the data you need, and use the time you saved on more important things!

You might also like

Nicolae Rotaru
Nicolae Rotaru
2022-07-27 - 5 min read

How to Scrape Airbnb Data: Pricing, Ratings, Amenities (Code & No code)

In this article, you will find an easy way to scrape Airbnb listings with Page2API using one of your favorite programming languages or a no-code solution that will import the data to Google Sheets

Nicolae Rotaru
Nicolae Rotaru
2022-05-29 - 5 min read

How to Scrape Yahoo Finance Stock Pricing Data (+ No code)

This article will describe the easiest way to scrape Stock Pricing Data from Yahoo Finance with Page2API

Nicolae Rotaru
Nicolae Rotaru
2022-05-21 - 4 min read

How to Scrape Reddit Data: Posts, Images, Comments, and more.

In this article, you will discover the easiest way to scrape Reddit data with Page2API

What customers are saying

Superb support
Superb, reliable support, even out of hours, patient and polite plus educational.
October 21, 2023
Very effective and trustworthy
Very effective and trustworthy!
I had some challenges which were addressed right away.
October 12, 2023
Page2API is without fail my favorite scraping API
Not only does Page2API work without fail constantly, but their customer support team is on a new level.
If i ever have issues integrating or have errors in my code they've always been responsive almost instantly and helped fix any errors.
I've never seen customer service like this anywhere, so massive thanks to the Page2API team.
July 14, 2023
Amazing product and support!
I have tried a lot of different scraping solutions and Page2Api is definitely the best one. It's very developer-friendly and Nick is extremely innovative in coming up with new ideas to solve problems.
The support is unreal as well.
I have sent Nick a request that I have trouble scraping and he's helped me fix all of them. Can highly recommend.
April 13, 2023
This API is amazing and the support was GREAT
This API is amazing and I am very excited to keep using it.
I'm writing this review because I was stumped on a very hard scrape for youtube transcripts, I brought my issue to support and in no time they had written what looks like a very tailored and complicated API call for me, I tested it and it worked perfect! Great great support.
April 19, 2023
Excellent service, super technical support!
I have been looking for such a quality for a long time, I have never met such an individual approach to clients.
Everything is at the highest level!
Nick very quickly helped to deal with all my questions, I am very grateful to him!
February 08, 2023
Fantastic Product and Customer Service
I'm a no-code guy trying to hack it in an API world... so I was pretty apprehensive about what I would be getting into with this.
I'm please to say that the customer service is so fantastic that they got me a solution in under 30 seconds that worked instantly in my application.
They did a great job and it works exactly as advertised.
Highly recommend them!
March 24, 2023
Surprisingly great service and support
I have certainly not come across any other internet initiative in the internet world that provides such good technical support and tries to help even if they are not related to them.
I will take as an example the approach of page2api to the customer in the startups I have founded.
February 16, 2023
Perfect for webcrapping javascript generated webpages
Page2API is perfect to be use from bubble or any other nocode tool.
It works submitting forms, scrapping info, and loading javascript generated content in webpages.
January 22, 2023
Best scraping service - tried them all
Hands down the best scraping service there is for a no-coder (...and I've tried them all).
Fast, easy to use, great documentation and stellar support.
Wish I'd found this months and months ago of waisting time at others. Highly recommend!
May 05, 2023
The best web scraper API for Bubble apps
Having tried several web scraper APIs I have found that Page2API is the best web scraper API for integrating with the Bubble API connector.
If you're a Bubble app developer Page2API is the web scraper you've been looking for!
November 30, 2022
Customer service is WORLD CLASS
Nick is serious about his business -- super knowledgeable and helpful whenever we have the slightest problem.
Honestly, the best customer service of any SaaS I've had the pleasure of working with.
December 02, 2022
It's a perfect product
This team has a very high sense of responsibility for the product.
They let me know the part I don't know so kindly.
I didn't feel any discomfort when I used it in Korea
June 12, 2023
Highly professional support!
Amazing quick support!
But more than that, an actual relevant and pro help which solved my issue.
April 19, 2023
Nick was incredible.
He helped me so much.
Need it for a research project and I highly highly recommend this service.
December 21, 2022
Great product, great support
I was searching for a scraping tool which fits to different types of needs and found Page2API.
The support is amazing and the product, too!
We will use Page2API also for our agency clients now.
Thank you for this great tool!
March 07, 2023
Really good provider for web-scraping…
Really good provider for web-scraping services, their customer service is top notch!
January 25, 2023
Great service with absolutely…
Great service with absolutely outstanding support
December 01, 2022

Ready to Scrape the Web like a PRO?

1000 free API calls.
Based on all requests made in the last 30 days. 99.85% success rate.
Trustpilot stars 4.6