目录

Google Maps Scraping in Pure Java

Google Maps scraping demands a solid understanding of code, browser emulation, proxies, and reCAPTCHA solvers. Google has dynamic content. Therefore, you should be able to adapt to any changes that it may make.

Primarily, you will need to mimic the behavior of a real user via browser emulation. Utilizing  or other browser emulators could be a practical approach. Second, you must use 代理人 if you wish to protect your office/home IP address, enabling you to request websites from the IPs of other users.

Google can perhaps display you with reCAPTCHA and bind it to some of your IPs, despite all that set of tools, when you have fair usage. For that reason, you can add a  reCAPTCHA解算器 if you do not wish to alter your IP address each time you encounter a reCAPTCHA.

Moreover, you should always be ready for the possibility that Google will alter the content of its website. You can accomplish this by conducting testing daily.

Despite the fact that implementation of the scraper could take a while, it is still possible to construct and maintain it. For additional information, take a look at this comprehensive guide that explains how to scrape Google Maps by utilizing Python and Selenium: How to Scrape Google Maps with Python and Selenium.

Google Maps Scraping With Outscraper Java Package

使用 Outscraper Java library will make scraping Google Maps much easier and more dependable. It provides convenient access to the Outscraper API from applications written in the Java language, which allows you to use Outscraper的服务 从你的代码中。

你可以先安装 该包裹 并在以下网站创建一个账户 Outscraper.

安装

Install the Outscraper SDK by using Maven, or Gradle.

Gradle

Edit your build.gradle file:

				
					repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    implementation 'com.github.outscraper:outscraper-java:v1.0.4'
}
				
			

Maven

Add the JitPack repository to your build file:

				
						<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>
				
			

Add the dependency:

				
						<dependency>
	    <groupId>com.github.outscraper</groupId>
	    <artifactId>outscraper-java</artifactId>
	    <version>v1.0.4</version>
	</dependency>
				
			

初始化

通过导入类和添加你的秘密API密钥来初始化Outscraper客户端。你可以在以下网站上生成API密钥 个人资料页面.

				
					OutscraperClient client = new OutscraperClient("SECRET_API_KEY");
				
			

使用实例

以下是如何通过使用搜索查询从谷歌地图上搜刮地方的例子。

				
					// Search for businesses in specific locations:
JSONArray results = client.googleMapsSearchV2(new HashMap<String, Object>() {{
  put("query", "restaurants brooklyn usa");
  put("limit", 20);
  put("language", "en");
  put("region", "us");
}});
System.out.println(results);
				
			

也可以通过使用地点标识来提取数据。

				
					// Get data of the specific place by id
JSONArray results = client.googleMapsSearchV2(new HashMap<String, Object>() {{
  put("query", "ChIJrc9T9fpYwokRdvjYRHT8nI4");
  put("language", "en");
}});
System.out.println(results);
				
			

现在就试试Outscraper SDK

You may now scrape Google Maps with Java without any hassle thanks to the Outscraper SDK. You are welcome to test out the service with our Free Tier at no cost.

常见问题

最常见的问题和答案

你可以通过使用Outscraper SDK刮取谷歌地图结果。指定搜索查询、语言和其他参数,并发送您的请求。

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.outscraper</groupId>
<artifactId>outscraper-java</artifactId>
<version>v1.0.4</version>
</dependency>
OutscraperClient client = new OutscraperClient("SECRET_API_KEY");
// Search for businesses in specific locations:
JSONArray results = client.googleMapsSearchV2(new HashMap<String, Object>() {{
put("query", "restaurants brooklyn usa");
put("limit", 20);
put("language", "en");
put("region", "us");
}});
System.out.println(results);

刮取谷歌地图需要良好的编码知识、浏览器模拟、代理和 reCAPTCHA解算器。 此外,你也应该准备好应对谷歌可能对其动态内容做出的改变。

谷歌地图不允许搜刮。虽然,搜刮和提取公共数据是受美国宪法第一修正案保护的。

类别: API

尤努斯

市场营销人员、内容写作人员、客户体验开发人员----。 Facebook | 领英 | 推特

0 评论

发表回复

头像占位符