جدول المحتويات

Google Maps Scraping in Pure Node.js

A good level of knowledge of computer programming, browser emulation, proxies, and reCAPTCHA solver is important for extracting Google Maps. Likewise, you must be prepared to deal with any changes Google may make to its adaptive content.

In order to effectively employ browser emulation, you will first need to simulate the actions of the actual user. Using Selenium or other browser emulators may be a viable option.

Then, you will need to make use of proxies in the second place if you want to protect the IP address of your workplace or your private residence. Because of this, you will be able to request websites from the IP addresses of other users.

You do not want your IPs switched whenever a reCAPTCHA occurs; therefore, you can add a reCAPTCHA solver to your system, as Google may still display a reCAPTCHA and connect it to some of your IPs despite that collection of tools. This could happen even if you have a good amount of traffic.

Plus, there are times when Google may actually change the information it provides. Simple daily testing will get the job done.

Putting a scraper into effect can be an extensive process, but it can be done and developed eventually. For further information on scraping Google Maps using Python and Selenium, have a look at this detailed guide: How to Scrape Google Maps with Python and Selenium.

Google Maps Scraping With Outscraper Node.js Package

Using the Outscraper Node.js library will enhance the quality of scraping Google Maps. It provides convenient access to the Outscraper API from applications written in the Node.js language, which allows you to use Outscraper’s services from your code.

You can start by installing the package and creating an account at Outscraper.

Installation

Install the Outscraper SDK by running the following command:

				
					npm install outscraper --save
# Or
yarn add outscraper
				
			

Initialization

Initialize the Outscraper client by importing the class and adding your secret API key. You can generate the API key on صفحة الملف الشخصي.

				
					const Outscraper = require('outscraper');
// Or using ES modules:
import Outscraper from 'outscraper';

let client = new Outscraper('SECRET_API_KEY');
				
			

Usage Examples

Here are examples of how you can scrape places from Google Maps by using search queries:

				
					// Search for businesses in specific locations:
client.googleMapsSearch(['restaurants brooklyn usa'], limit=20, language='en', region='us').then(response => {
  console.log(response);
});


// Scrap Places by Two Queries
client.googleMapsSearch(
  ['restaurants brooklyn usa', 'bars brooklyn usa'],
  limit=50, // limit of palces per each query
  language='en',
  region='US',
).then(response => {
  response.forEach(queryPlaces => {
    queryPlaces.forEach(place => {
      console.log('--------------------');
      console.log('query: ', place.query);
      console.log('name: ', place.name);
      console.log('phone: ', place.phone);
      console.log('site: ', place.site);
    });
  });
});
				
			

It’s also possible to extract the data by using Place Id:

				
					// Get data of the specific place by id
client.googleMapsSearch(['ChIJrc9T9fpYwokRdvjYRHT8nI4'], language='en').then(response => {
  console.log(response);
});

// Scrap Places by Place Ids
client.googleMapsSearch(
  ["ChIJ8ccnM7dbwokRy-pTMsdgvS4", "ChIJN5X_gWdZwokRck9rk2guJ1M", "ChIJxWLy8DlawokR1jvfXUPSTUE"],
  limit=1, // limit of palces per each query
).then(response => {
  response.forEach(queryPlaces => {
    queryPlaces.forEach(place => {
      console.log('--------------------');
      console.log('name: ', place.name);
      console.log('place_id: ', place.place_id);
    });
  });
});
				
			

Try Outscraper SDK Now

The Outscraper SDK has made it simple and provides an efficient way available for you to easily do Google Maps scraping with Node.js. Simply sign up to give our Free Tier a try.

التعليمات

الأسئلة والأجوبة الأكثر شيوعًا

يمكنك كشط نتائج خرائط Google باستخدام Outscraper SDK. حدد استعلامات البحث واللغة والمعلمات الأخرى، وأرسل طلبك.

تثبيت npm outscraper - حفظ
# أو
غزل إضافة outscraper
const Outscraper = يتطلب('outscraper');
// أو باستخدام وحدات ES:
استيراد Outscraper من 'outscraper';

دع العميل = Outscraper الجديد('SECRET_API_KEY');
// ابحث عن الأنشطة التجارية في مواقع محددة:
العميل.googleMapsSearch(['مطاعم بروكلين الولايات المتحدة الأمريكية']، الحد=20، اللغة='en'، المنطقة='الولايات المتحدة').then(الاستجابة => {
  console.log(response);
});


// كشط الأماكن باستعلامين
client.googleMapsSearch(
  ['مطاعم بروكلين الولايات المتحدة الأمريكية'، 'حانات بروكلين الولايات المتحدة الأمريكية'],
  الحد=50, // حد الأماكن لكل استعلام
  اللغة='en',
  المنطقة='الولايات المتحدة',
).then(الاستجابة => {
  response.forEach(queryPlaces.forEach(queryPlaces => {
    queryPlaces.forEach(المكان => {
      console.log('--------------------');
      console.log('استعلام: '، place.query.query);
      console.log('name: '، place.name);
      console.log('phone: ', ', place.phone);
      console.log('site: ', ', place.site);
    });
  });
});

يتطلب مسح خرائط جوجل معرفة جيدة بالترميز، ومحاكاة المتصفح، والبروكسيات، و مُحلل reCAPTCHA. بالإضافة إلى ذلك، يجب أن تكون مستعدًا أيضًا للتعامل مع التغييرات التي قد تجريها جوجل على محتواها الديناميكي.

لا تسمح خرائط جوجل بالكشط. على الرغم من أن كشط واستخراج البيانات العامة محمي بموجب التعديل الأول لدستور الولايات المتحدة.


يونس

مسوِّق، كاتب محتوى، مطور تجربة العملاء - مسوِّق، كاتب محتوى، مطور تجربة العملاء - فيسبوك | لينكد إن | تويتر

0 Comments

اترك تعليقاً

عنصر نائب للصورة الرمزية