Skip to content

piotrv1001/how-to-scrape-yelp-in-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to Scrape Yelp Business Listings in Node.js

A minimal Node.js example that scrapes Yelp business listings by calling the Yelp Business Scraper Apify actor. You don't build a scraper from scratch here — the actor handles the crawling, parsing, and anti-blocking, and you just call it and read the results.

Yelp Business Scraper results

What this example does

  • Calls the piotrv1001/yelp-business-scraper Apify actor
  • Passes a search input (a search term and location)
  • Waits for the run to finish
  • Fetches the results from the run's dataset
  • Prints each business listing to the console

Prerequisites

Installation

npm install

Environment setup

Copy the example env file and add your Apify API token:

cp .env.example .env

Then edit .env:

APIFY_TOKEN=your_apify_token_here

Usage

npm start

Code example

import { ApifyClient } from 'apify-client';
import 'dotenv/config';

// Initialize the ApifyClient with your Apify API token
// Set APIFY_TOKEN in your .env file (copy .env.example to get started)
const client = new ApifyClient({
    token: process.env.APIFY_TOKEN,
});

// Prepare Actor input
const input = {
    "search": "Sushi",
    "location": "New York, NY"
};

// Run the Actor and wait for it to finish
const run = await client.actor("piotrv1001/yelp-business-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

Example output

See sample-output.json for a full example of what the actor returns. Each business listing includes key fields such as:

  • name, alias, url — business identity and Yelp page
  • rating, reviewCount, reviewCountText — review metrics
  • priceRange, categories, neighborhood — classification
  • reviewSnippet, thumbnail — a preview review and image
  • phone, address, website — contact details
  • rank, scrapedAt — result position and timestamp

Use cases

  • Build a local restaurant or business directory
  • Generate sales leads from businesses in a target city
  • Monitor ratings and review counts of competitors
  • Enrich a CRM with phone numbers, addresses, and websites
  • Power market research on a category or neighborhood

Try the actor on Apify

Open the Yelp Business Scraper on Apify

Related resources

License

MIT

About

How to scrape Yelp business listings in Node.js using the Apify Yelp Business Scraper actor.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors