npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

google-reviews-web-scraper

v1.0.2

Published

Retrieves google reviews through a web scraper and returns it as a json array

Downloads

12

Readme

node-google-reviews-web-scraper

Get the reviews from any google maps business 🗺

Contributions are highly appreciated !


npm install google-reviews-web-scraper

setup :

npm install

npm run start (launches program with nodemon)

New in 1.0.2 !

  • Set the output method of the getReviews method with an optional second argument : "json" or "object". The default is "json".

Description

This project aims to scrape data from the google maps business page in order to get the reviews (it's not in the api, why google ?)

Technologies used

  • Puppeteer
  • Express
  • NodeJS (duh)

Usage

There is a webserver in there, you can run it with npm run serve, and connect to localhost:3000 to get a json response with the url in the script. However, it is WIP so the point is just to return the data.

You can also run npm run start, which will show you the eiffel tower reviews (in french, cocorico !).

Re-use the code

There is only one interesting function inside the getReviws.js file, and it's the getReviews(url) method.

const getReviews = async (url) => {
    /**
     * Steps :
     * Open headless chrome with puppeteer
     * load the link
     * evaluate js expressions in the headless chrome instance 
     * return a slue of the interesting data.
     */
};

as it is exported, you can take this file and import the method by doing something like this :

const getReviews = require('./getReviews');

Import it with NPM

If you installed it with npm, you can do the following

const getReviews = require('google-reviews-web-scraper');

and then, calling the mod with the following args :

getReviews(url);

where url is a string. A google maps business url looks like this :

https://www.google.com/maps/place/Tour+Eiffel/@48.8583736,2.292298,17z/data=!4m5!3m4!1s0x47e66e2964e34e2d:0x8ddca9ee380ef7e0!8m2!3d48.8583701!4d2.2944813

The json object returned by the api looks like this :

{
  "reviewAuthorNames": [
    "Alexandre MASSON",
    "Caroline Nédélec",
    "Romain VILCOQ"
  ],
  "dates": ["il y a 5 jours", "il y a 2 semaines", "il y a 2 semaines"],
  "ratings":[5, 5, 5],
  "reviewsContent": [
    "Magnifique et incontournable monument de la capitale française. A absolument faire lors de votre visite parisienne ! Haute de 321 mètres, cette tour de fer surplombe la région parisienne. Véritable prouesse architecturale et scientifique, …",
    "Un lieu toujours magnifique. Attention ne vous faites pas photographier de force par tous ces photographes qui traînent dans la tour et qui veulent vous vendre des photos à prix d'or. Évidemment les prix ne sont pas affichés et le tarif est …",
    "La dame de fer est l'emblème de notre capitale, le monument à visiter en priorité. \nLa vue depuis le sommet est incontournable !\nL'ascension par les escaliers est une belle expérience et permet de profiter au mieux de la structure, cependant elle est réservée aux plus sportifs. La descente est possible également 😉"
  ]
}