Оглавление

Скраппинг Google Maps в чистом 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 Селен or other browser emulators may be a viable option.

Then, you will need to make use of прокси 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 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 с помощью пакета Outscraper Node.js

Использование Библиотека Outscraper Node.js will enhance the quality of scraping Google Maps. It provides convenient access to the API Outscraper from applications written in the Node.js language, which allows you to use Услуги Outscraper из вашего кода.

Вы можете начать с установки пакет и создать учетную запись на Outscraper.

Установка

Установите Outscraper SDK, выполнив следующую команду:

				
					npm install outscraper --save
# Or
yarn add outscraper
				
			

Инициализация

Инициализируйте клиент Outscraper, импортировав класс и добавив секретный ключ API. Вы можете сгенерировать ключ API на страница профиля.

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

let client = new Outscraper('SECRET_API_KEY');
				
			

Примеры использования

Ниже приведены примеры того, как можно получить информацию о местах из Google Maps с помощью поисковых запросов:

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


// Scrap Places by Two Queries
client.googleMapsSearchV2(
  ['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);
    });
  });
});
				
			

Также можно извлечь данные с помощью Place Id:

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

// Scrap Places by Place Ids
client.googleMapsSearchV2(
  ["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);
    });
  });
});
				
			

Попробуйте Outscraper SDK сейчас

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 Map с помощью Outscraper SDK. Укажите поисковые запросы, язык и другие параметры и отправьте запрос.
npm install outscraper --save
# Или
yarn add outscraper
const Outscraper = require('outscraper');
// Или используя ES модули:
import Outscraper from 'outscraper';

let client = new Outscraper('SECRET_API_KEY');
// Поиск предприятий в определенных местах:
client.googleMapsSearchV2(['restaurants brooklyn usa'], limit=20, language='en', region='us').then(response => {
  console.log(response);
});


// Поиск мест по двум запросам
client.googleMapsSearchV2(
  ['restaurants brooklyn usa', 'bars brooklyn usa'],
  limit=50, // ограничение количества мест по каждому запросу
  язык='en',
  регион='США',
).then(response => {
  response.forEach(queryPlaces => {
    queryPlaces.forEach(place => {
      console.log('--------------------');
      console.log('запрос: ', place.query);
      console.log('name: ', place.name);
      console.log('phone: ', place.phone);
      console.log('site: ', place.site);
    });
  });
});

Скраппинг Google Maps требует хорошего знания кодирования, эмуляции браузера, прокси и Решение проблемы reCAPTCHA. Кроме того, вы должны быть готовы к изменениям, которые Google может внести в динамический контент.

Карты Google запрещают скрапбукинг. Хотя скраппинг и извлечение публичных данных защищены Первой поправкой к Конституции США.

Категории: API

Юнус

Маркетолог, писатель контента, разработчик клиентского опыта - Facebook | Linkedin | Твиттер

0 Комментарии

Добавить комментарий

Заполнитель аватара