This repository contains a Node.js script that uses Puppeteer to scrape services from Google Search. The script extracts data such as the name, phone number, address, services offered, rating, and reviews, and saves it into a CSV file.
It can be used to scrape various types of services. For example, you can scrape all restaurants in London with the following details:
- Service name
- Phone number
- Address
- Services offered
- Rating
- Number of reviews
- Scrapes data from Google Search.
- Extracts the following details:
- Service name
- Phone number
- Address
- Services offered
- Rating
- Number of reviews
- Saves the scraped data to a CSV file.
- Node.js (version 14 or above recommended)
- Puppeteer or puppeteer-core (browser installation required if using
puppeteer-core)
npm installIf you are using puppeteer-core, install the Chrome browser:
npx puppeteer browsers install chromeTo run the script, you'll need to pass a URL to a Google Local Services search results page and specify the output CSV filename.
The url to be passed should be from this page
const url = 'https://www.google.com/localservices/prolist?...';
const filename = 'services.csv';- Open
index.jsand update theurlandfilenamevariables with the desired values. - Run the script:
npm startThe script will output a CSV file containing the following columns:
name: The name of the service.phoneNumber: The phone number of the service.address: The address of the service.services: The services offered by the service.rating: The Google rating of the service.reviews: The number of reviews.
If you encounter an error like:
Error: Could not find Chrome (ver. 125.0.6422.78)...Make sure to install the Chrome browser for Puppeteer with:
npx puppeteer browsers install chrome- Puppeteer - A Node.js library to control headless Chrome.
- json2csv - Converts JSON data into CSV format.
If you'd like to contribute, feel free to fork the repository and submit a pull request!
This project is licensed under the MIT License - see the LICENSE file for details.
