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

Google Maps Scraping in Pure PHP

Good knowledge of coding, browser emulation, proxies, and reCAPTCHA solver is required for scraping Google Maps. Additionally, it would help if you were prepared to deal with any modifications Google may make to its dynamic content.

Initially, you will need to emulate the behavior of a real user via browser emulation. Therefore, using السيلينيوم or other browser emulators could be an efficient option.

You must use الوكلاء if you wish to protect your office/home IP address, thus, you can request websites from the IPs of other users.

Even with this array of tools, Google may present you with reCAPTCHA and bind it to some of your IPs if you have sufficient usage. You can add a  أداة حل reCAPTCHA if you do not want to alter IPs whenever you encounter a reCAPTCHA.

Besides this, be prepared for the possibility that Google may alter its content. It can be achieved by conducting daily tests.

Even though implementing the scraper may take some time, it can be built and maintained. To learn how to scrape Google Maps using Python and Selenium, visit this step-by-step tutorial: كيفية استخراج البيانات من خرائط جوجل باستخدام لغة بايثون وبرنامج سيلينيوم.

Google Maps Scraping With Outscraper PHP Package

A more robust way of scraping Google Maps will be using the Outscraper PHP library. It provides convenient access to the واجهة برمجة التطبيقات Outscraper from applications written in the PHP language which allows you to use خدمات Outscraper من الكود الخاص بك.

يمكنك البدء بتثبيت الطرد وإنشاء حساب على Outscraper.

التركيب

Composer

Install the Outscraper SDK via Composer. Run the following command:

				
					composer require outscraper/outscraper
				
			

To use the bindings, use Composer’s autoload:

				
					require_once('vendor/autoload.php');
				
			

Manual Installation

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file:

				
					require_once('/path/to/outscraper-php/init.php');
				
			

التهيئة

قم بتهيئة عميل Outscraper عن طريق استيراد الفئة وإضافة مفتاح API السري الخاص بك. يمكنك إنشاء مفتاح API على صفحة الملف الشخصي.

				
					$client = new OutscraperClient("SECRET_API_KEY");
				
			

أمثلة على الاستخدام

فيما يلي أمثلة على كيفية استخراج بيانات المواقع من خرائط جوجل باستخدام استعلامات البحث:

				
					# Search for businesses in specific locations:
$results = $client->google_maps_search_v2(['restaurants brooklyn usa'], limit: 20, language: 'en', region: 'us');

# Scrap Places by Two Queries
$results = $client->google_maps_search_v2(
    ['restaurants brooklyn usa', 'bars brooklyn usa'],
    limit: 50, # limit of palces per each query
    language: 'en',
    region: 'US',
);

# Iterate over the results
foreach ($results as &$query_places) {
    foreach ($query_places as &$place) {
        print($place['query']);
        print($place['name']);
        print($place['phone']);
        print($place['site']);
    }
};
				
			

كما يمكن استخراج البيانات باستخدام معرّف المكان (Place ID):

				
					# Get data of the specific place by id
$results = $client.google_maps_search_v2(['ChIJrc9T9fpYwokRdvjYRHT8nI4'], language: 'en');

# Scrap Places by Place Ids
$results = $client->google_maps_search_v2(
    ["ChIJ8ccnM7dbwokRy-pTMsdgvS4", "ChIJN5X_gWdZwokRck9rk2guJ1M", "ChIJxWLy8DlawokR1jvfXUPSTUE"],
    limit: 1, # limit of palces per each query
);

# Iterate over the results
foreach ($results as &$query_places) {
    foreach ($query_places as &$place) {
        print($place['query']);
        print($place['place_id']);
    }
};
				
			

جرب Outscraper SDK الآن

The Outscraper SDK is available for you to easily do Google Maps Scraping with PHP. You can try it right now with a Free Tier.

التعليمات

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

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

composer require outscraper/outscraper
require_once('vendor/autoload.php');
$client = new OutscraperClient("SECRET_API_KEY");
# Search for businesses in specific locations:
$results = $client->google_maps_search_v2(['restaurants brooklyn usa'], limit: 20, language: 'en', region: 'us');
# Scrap Places by Two Queries
$results = $client->google_maps_search_v2(
['restaurants brooklyn usa', 'bars brooklyn usa'],
limit: 50, # limit of palces per each query
language: 'en',
region: 'US',
);
# Iterate over the results
foreach ($results as &$query_places) {
foreach ($query_places as &$place) {
print($place['query']);
print($place['name']);
print($place['phone']);
print($place['site']);
}
};

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

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


يونس

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

0 Comments

اترك تعليقاً

Avatar placeholder