我们可以在 Google 上抓取和解析各种页面类型。您可以向我们提供一个完整的URL 或通过专门建立的页面类型提供一些输入参数(如搜索 ,广告 , 酒店 , 和其他),所以我们可以在我们的终端形成 URL。
注意 :SERP 爬虫 API 在抓取时可以渲染 JavaScript 。这在一些 Google 服务中是有必要的,例如 旅行 。
总览
以下概述我们通过 Google 支持的所有可用数据source
值 。
SERP,针对最大广告率进行优化。 仅 num=10
。
您可以通过选择菜单右侧的名称跳转至您喜欢的 Google 页面类型。每个页面都包含参数表以及代码示例,可帮助您开始查询。
URL
google
源设计用于检索各种 Google URL 中的内容。这意味着,您可以向我们提供一个转至所需 Google 页面的直接 URL,而不是发送多个参数。我们不会剥离任何参数或以任何其他方式更改您的 URL。
这个数据源也支持解析数据(JSON 格式的结构化数据),只要提交的 URL 用于 Google(SERP 页面)。如果我们不能确认这是一个 SERP 页面请求,我们将返回一个故障信息。
查询参数
这些结果将根据地理位置进行调整。正确使用这个参数对获得准确的数据极为重要。欲了解更多信息,请在此处 阅读我们建议的 geo_location 参数结构。
- 必须提供的参数
代码示例
在以下示例中,API 将检索一个 Google Scholar 搜索页面。
JSON cURL Python PHP HTTP
Copy {
"source": "google",
"url": "https://scholar.google.com/scholar?hl=en&q=newton&btnG=&as_sdt=1%2C5&as_sdtp="
}
Copy curl --user user:pass1 'https://realtime.oxylabs.io/v1/queries' -H "Content-Type: application/json"
-d '{"source": "google", "url": "https://scholar.google.com/scholar?hl=en&q=newton&btnG=&as_sdt=1%2C5&as_sdtp="}{"source": "google", "url": "https://scholar.google.com/scholar?hl=en&q=newton&btnG=&as_sdt=1%2C5&as_sdtp="}'
Copy import requests
from pprint import pprint
# Structure payload.
payload = {
'source': 'google',
'url': 'https://scholar.google.com/scholar?hl=en&q=newton&btnG=&as_sdt=1%2C5&as_sdtp='
}
# Get response.
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('user', 'pass1'),
json=payload,
)
# Instead of response with job status and results url, this will return the
# JSON response with results.
pprint(response.json())yhon
Copy <?php
$params = array(
'source' => 'google',
'url' => 'https://scholar.google.com/scholar?hl=en&q=newton&btnG=&as_sdt=1%2C5&as_sdtp='
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://data.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
Copy # URL has to be encoded to escape `&` and `=` characters:
# URL: https://scholar.google.com/scholar?hl=en&q=newton&btnG=&as_sdt=1%2C5&as_sdtp=
# Encoded URL: https%3A%2F%2Fscholar.google.com%2Fscholar%3Fhl%3Den%26q%3Dnewton%26btnG%3D%26as_sdt%3D1%252C5%26as_sdtp%3D
https://realtime.oxylabs.io/v1/queries?source=google&url=https%3A%2F%2Fscholar.google.com%2Fscholar%3Fhl%3Den%26q%3Dnewton%26btnG%3D%26as_sdt%3D1%252C5%26as_sdtp%3D&access_token=12345abcde
以上示例使用了 Realtime 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。
搜索
google_search
源设计用于检索 Google Search 结果(SERP)。
查询参数
Accept-Language
标头值,它可以更改您的 Google 搜索页面的网页界面语言。更多信息 。
结果应适应的地理位置。正确使用这个参数对获得正确数据极为重要。欲了解更多信息,请在此处 阅读我们建议的 geo_location
参数结构。
true
将返回解析数据。查看结构化数据 了解更多信息。
设置 fpstate
值为 aig
将使 Google 加载更多应用程序。这个参数只有在与渲染
参数一起使用时才有用。
如果要使用相同的IP地址抓取多个页面,请包含一个JSON数组,并使用 page
键指定页面数量。还必须通过添加 limit
键来指示每个页面上的自动搜索结果数,例如:
Copy "context": [{
"key": "limit_per_page",
"value": [
{"page": 1, "limit": 10},
{"page": 2, "limit": 90}
]
}]
context
:
results_language
结果语言。您可以在这里 找到一个支持的 Google 语言列表。
待配或 tbm
参数。可接受的值是:app
、blg
、bks
、dsc
、isch
、nws
、pts
、plcs
、rcp
、lcl
。
ttbs
参数这个参数就像一个容器,用于存放更多无名 Google 参数,比如按日期限制/排序结果,以及其他过滤器,其中一些取决于 tbm
参数(例如 tbs=app_os:1
只适用于 tbm
值 app
).单击此处 了解更多相关信息。
- 必须提供的参数
代码示例
在以下示例中,我们请求从 google.nl
域获得 2
个结果页面,从第 11
页到第 12
页,搜索词为 adidas
。SERP 将被过滤,只包含法语的结果。
JSON cURL Python PHP HTTP
Copy {
"source": "google_search",
"domain": "nl",
"query": "adidas",
"start_page": 11,
"pages": 2,
"parse": true,
"context": [
{
"key": "results_language",
"value": "fr"
}]
}
Copy curl --user user:pass1 'https://realtime.oxylabs.io/v1/queries' -H "Content-Type: application/json"
-d '{"source": "google_search", "domain": "nl", "query": "adidas", "start_page": 11, "pages": 2, "parse": true, "context": [{"key": "results_language", "value": "fr"}]}'
Copy import requests
from pprint import pprint
# Structure payload.
payload = {
'source': 'google_search',
'domain': 'nl',
'query': 'adidas',
'start_page': 11,
'pages': 2,
'context': [
{'key': 'results_language', 'value': 'fr'},
],
}
# Get response.
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('user', 'pass1'),
json=payload,
)
# Print prettified response to stdout.
pprint(response.json())
Copy <?php
$params = array(
'source' => 'google_search',
'domain' => 'nl',
'query' => 'adidas',
'start_page' => 11,
'pages' => 2,
'context' => array(
'key' => 'results_language',
'value' => 'fr'
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>hp
Copy https://realtime.oxylabs.io/v1/queries?source=google_search&domain=nl&query=adidas&start_page=11&pages=2&context[0][key]=results_language&context[0][value]=fr&access_token=12345abcde
以上示例使用了 Realtime 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。
广告
google_ads
源被优化为检索带有付费广告的 Google Search 结果页(SERP)。这个来源每页只返回十个结果,确保显示付费结果的机会最高。除此以外,它支持与常规 搜索 相同的参数。
查询参数
Google 的域名本地化。单击此处 查看可用域名的完整列表。
Accept-Language
标头值,它可以更改您的 Google 搜索页面的网页界面语言。更多信息 。
结果应适应的地理位置。正确使用这个参数对获得正确数据极为重要。欲了解更多信息,请在此处 阅读我们建议的 geo_location
参数结构。
true
将返回结构化数据。查看结构化数据 了解更多信息。
context
:
results_language
结果语言。您可以在这里 找到一个支持的 Google 语言列表。
待配或 tbm
参数。可接受的值是:app
、blg
、bks
、dsc
、isch
、nws
、pts
、plcs
、rcp
、lcl
。
tbs
参数这个参数就像一个容器,用于存放更多无名 google 参数,比如按日期限制/排序结果以及其他过滤器,其中一些取决于tbm
参数(例如 tbs=app_os:1
只适用于 tbm
值 app
).单击此处 了解更多相关信息。
- 必须提供的参数
代码示例
在这个示例中,我们向 google.nl
发送请求检索关键字 adidas
的搜索结果。
JSON cURL Python PHP HTTP
Copy {
"source": "google_ads",
"domain": "nl",
"query": "adidas",
"parse": true
}
Copy curl --user user:pass1 'https://realtime.oxylabs.io/v1/queries' -H "Content-Type: application/json"
-d '/{
"source": "google_ads",
"domain": "nl",
"query": "adidas",
"parse": true
}'
Copy import requests
from pprint import pprinthp
# Structure payload.
payload = {
'source': 'google_ads',
'domain': 'nl',
'query': 'adidas'
}
# Get response.
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('user', 'pass1'),
json=payload,
)
# Print prettified response to stdout.
pprint(response.json())
Copy <?php
$params = array(
'source' => 'google_ads',
'domain' => 'nl',
'query' => 'adidas'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
Copy https://realtime.oxylabs.io/v1/queries?source=google_ads&domain=nl&query=adidas
以上示例使用了 Realtime 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。
酒店
google_hotels
数据源设计用于检索 Google Hotel 搜索结果。
查询参数
Accept-Language
标头值,它可以更改您的 Google 搜索页面的网页界面语言。更多信息 。
结果语言。您可以在这里 找到一个支持的 Google 语言列表。
结果应适应的地理位置。正确使用这个参数对获得正确数据极为重要。欲了解更多信息,请在此处 阅读我们建议的 geo_location
参数结构。
入住酒店时长,入住日期 - 离开日期。示例:2023-07-12,2023-07-13
。
- 必须提供的参数
注意 :使用 Google hotel,您始终需要发送一个包含“酒店”一词的关键词 例如,“洛杉矶的酒店”,“法国巴黎的酒店”,等等。“宾馆”和“酒店”都可以。Google 还支持当地语言,为赫尔辛基的酒店发送“Hotelli Helsingissä”,为维尔纽斯的酒店发送“viešbučiai Vilnius”。
代码示例
在这个示例中,我们请求从
google.com.sons. 检索前
3 页页面,以查询
2023-10-01 至
2023-10-10期间在巴黎是否
有可容纳1
名客人的酒店。
JSON cURL Python PHP HTTP
Copy {
"source": "google_hotels",
"domain": "com",
"pages": 3,
"query": "hotels in Paris",
"context": [
{
"key": "hotel_occupancy",
"value": 1
},
{
"key": "hotel_dates",
"value": "2023-10-01,2023-10-10"
}]
}
Copy curl --user user:pass1 'https://realtime.oxylabs.io/v1/queries' -H "Content-Type: application/json"
-d '{"source": "google_hotels", "domain": "com", "pages": 3, "query": "hotels in Paris", "context": [{"key": "hotel_occupancy", "value": 1}, {"key": "hotel_dates", "value": "2023-10-01,2023-10-10"}]}'
Copy import requests
from pprint import pprint
# Structure payload.
payload = {
'source': 'google_hotels',
'domain': 'com',
'query': 'hotels in Paris',
'pages': 3,
'context': [
{'key': 'hotel_occupancy', 'value': 1},
{'key': 'hotel_dates', 'value': '2023-10-01,2023-10-10'},
],
}
# Get response.
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('user', 'pass1'),
json=payload,
)
# Print prettified response to stdout.
pprint(response.json())
Copy <?php
$params = array(
'source' => 'google_hotels',
'domain' => 'com',
'query' => 'hotels in Paris',
'pages' => 3,
'context' => [
[
'key' => 'hotel_occupancy',
'value' => 1,
],
[
'key' => 'hotel_dates',
'value': '2023-10-01,2023-10-10',
]
]
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
Copy https://realtime.oxylabs.io/v1/queries?source=google_hotels&domain=com&query=hotels+in+Paris&pages=3&context[0][key]=hotel_occupancy&context[0][value]=1&context[1][key]=hotel_dates&context[1][value]=2023-10-01,2023-10-10&access_token=12345abcde
以上示例使用了 Realtime 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。
旅行:酒店
Google_travel_hotels
数据源设计用于检索 Google Travel 服务的酒店搜索结果。
查询参数
Accept-Language
标头值,它可以更改您的 Google 搜索页面的网页界面语言。更多信息 。
结果应适应的地理位置。正确使用这个参数对获得正确数据极为重要。请注意,这个来源可以接受数量有限的 geo_location
值 - 请检查 本节 来查看不 产生准确结果的geo_location
值。
按酒店星级过滤结果。您可以指定一个或多个介于2
和 5
之间的值.例如:[3,4]
住在酒店的日期,入住日期 - 离开日期。示例:2023-07-12,2023-07-13
- 必须提供的参数
注意 :请注意,使用 Google Hotels,您的关键词必须始终包括“酒店”,例如,“洛杉矶的酒店”、“法国巴黎的酒店”等。“宾馆”和“酒店”都可以。Google 还支持当地语言,为赫尔辛基的酒店发送“Hotelli Helsingissä”,为维尔纽斯的酒店发送“viešbučiai Vilnius”。
代码示例
在这个示例中,我们请求从 google.com 检索第 2
页结果页面,以查询 2023-10-01
至 2023-10-10
期间在巴黎是否有可容纳2
名客人的2
至 4
-星级酒店。
JSON cURL Python PHP HTTP
Copy {
"source": "google_travel_hotels",
"domain": "com",
"start_page": 2,
"query": "hotels in Paris",
"context": [
{
"key": "hotel_occupancy",
"value": 2
},
{
"key": "hotel_dates",
"value": "2023-10-01,2023-10-10"
},
{
"key": "hotel_classes",
"value": [2,4]
}]
}
Copy curl --user user:pass1 'https://realtime.oxylabs.io/v1/queries' -H "Content-Type: application/json"
-d '{"source": "google_travel_hotels", "domain": "com", "start_page": 2, "query": "hotels in Paris", "context": [{"key": "hotel_occupancy", "value": 2}, {"key": "hotel_dates", "value": "2023-10-01,2023-10-10"}, {"key": "hotel_classes", "value": [2,4]}]}'
Copy ythimport requests
from pprint import pprint
# Structure payload.
payload = {
'source': 'google_travel_hotels',
'domain': 'com',
'query': 'hotels in Paris',
'start_page': 2,
'context': [
{'key': 'hotel_occupancy', 'value': 1},
{'key': 'hotel_dates', 'value': '2023-10-01,2023-10-10'},
{'key': 'hotel_classes', 'value': [2,4]},
],
}
# Get response.
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('user', 'pass1'),
json=payload,
)
# Print prettified response to stdout.
pprint(response.json())
Copy <?php
$params = array(
'source' => 'google_travel_hotels',
'domain' => 'com',
'query' => 'hotels in Paris',
'start_page' => 2,
'context' => [
[
'key' => 'hotel_occupancy',
'value' => 1,
],
[
'key' => 'hotel_dates',
'value': '2023-10-01,2023-10-10',
],
[
'key' => 'hotel_classes',
'value' => [2,4],
]
]
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>php
Copy https://realtime.oxylabs.io/v1/queries?source=google_travel_hotels&domain=com&query=hotels+in+Paris&start_page=3&context[0][key]=hotel_occupancy&context[0][value]=1&context[1][key]=hotel_dates&context[1][value]=2023-10-01,2023-10-10&context[2][key]=hotel_classes&context[2][value]=[2,4]&access_token=12345abcde
以上示例使用了 Realtime 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。
图片
google_images
源设计用于检索图像搜索页面以查找与提供query
参数和包含这些图像的网站的图像相似的图像。
查询参数
Accept-Language
标头值,它可以更改您的 Google 搜索页面的网页界面语言。更多信息 。
结果应适应的地理位置。正确使用这个参数对获得正确数据极为重要。欲了解更多信息,请在此处 阅读我们建议的 geo_location
参数结构。
context
:
results_language
结果语言。您可以在 这里 找到一个支持 Google 语言的列表。
- 必须提供的参数
代码示例
在这个示例中,我们请求获得这个图像的反向图像搜索结果: 来自
google.com 的
https://newsneakernews-wpengine.netdna-ssl.com/wp-content/uploads/2017/03/adidas-boost-march-25-2017.jpg。
JSON cURL Python PHP HTTP
Copy {
"source": "google_images",
"domain": "com",
"query": "https://newsneakernews-wpengine.netdna-ssl.com/wp-content/uploads/2017/03/adidas-boost-march-25-2017.jpg",
"context": [
{
"key": "search_operators",
"value": [
{"key": "site", "value": "example.com"},
{"key": "filetype", "value": "html"},
{"key": "inurl", "value": "image"}
}],
"callback_url": "https://your.callback.url"
}
Copy curl --user user:pass1 'https://data.oxylabs.io/v1/queries'\
-H "Content-Type: application/json" \
-d '{"source": "google_images", "domain": "com", "query": "https://newsneakernews-wpengine.netdna-ssl.com/wp-content/uploads/2017/03/adidas-boost-march-25-2017.jpg", "context": [{"key": "search_operators","value": [{"key": "site", "value": "example.com"}, {"key": "filetype", "value": "html"}, {"key": "inurl", "value": "image"}}], "callback_url": "https://your.callback.url"}'
Copy import requests
from pprint import pprint
# Structure payload.
payload = {
'source': 'google_images',
'domain': 'com',
'query': 'https://newsneakernews-wpengine.netdna-ssl.com/wp-content/uploads/2017/03/adidas-boost-march-25-2017.jpg',
'context': [
{
'key': 'search_operators',
'value': [
{'key': 'site', 'value': 'example.com'},
{'key': 'filetype', 'value': 'html'},
{'key': 'inurl', 'value': 'image'}
]
}
]
}
# Get response.
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('user', 'pass1'),
json=payload,
)
# Print prettified response to stdout.
pprint(response.json())
Copy <?php
$params = array(
'source' => 'google_images',
'domain' => 'com',
'query' => 'https://newsneakernews-wpengine.netdna-ssl.com/wp-content/uploads/2017/03/adidas-boost-march-25-2017.jpg',
'context' => [
[
'key' => 'hotel_occupancy',
'value' => [
['key' => 'site', 'value' => 'example.com'],
['key' => 'filetype', 'value' => 'html'],
['key' => 'inurl', 'value' => 'image']
]
]
)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
Copy https://realtime.oxylabs.io/v1/queries?source=google_images&domain=com&query=https://www.example.com/img/image.jpg&access_token=12345abcde
以上示例使用了 Realtime 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。
建议
google_suggest
源设计用于检索 Google 的搜索术语建议。
查询参数
Accept-Language
标头值,它可以更改您的 Google 搜索页面的网页界面语言。更多信息 。
结果应适应的地理位置。正确使用这个参数对获得正确数据极为重要。欲了解更多信息,请在此处 阅读我们建议的 geo_location
参数结构。
- 必须提供的参数
代码示例
API 请求 Google Suggestions 页面检索关键词 adidas
的建议。
JSON cURL Python PHP HTTP
Copy {
"source": "google_suggest",
"query": "what is"
}
Copy curl --user user:pass1 'https://realtime.oxylabs.io/v1/queries' -H "Content-Type: application/json"
-d '{"source": "google_suggest", "query": "what is"}'
Copy import requests
from pprint import pprint
# Structure payload.
payload = {
'source': 'google_suggest',
'query': 'what is'
}
# Get response.
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('user', 'pass1'),
json=payload,
)
# Print prettified response to stdout.
pprint(response.json())
Copy <?php
$params = array(
'source' => 'google_suggest',
'query' => 'what is'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
Copy https://realtime.oxylabs.io/v1/queries?source=google_suggest&query=what%20is&access_token=12345abcde
以上示例使用了 Realtime 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。
关键字
google_msv_v2
数据源将检索指定关键字和建议关键字的 Google 关键字数据(除非在上下文中传递 idea=False)。
查询参数
结果应适应的地理位置。正确使用这个参数对获得正确数据极为重要。欲了解更多信息,请在此处 阅读我们建议的 geo_location
参数结构。
语言,例如,英语
或 法文
.没有参数或空值将返回所有语言的结果。
如果是true
,返回关键字的意思 ,如果是false
,将只返回所请求关键字的数据。
当获取意思时,将检索意思关键字的数量限制为已有限制,四舍五入到最接近的 50 倍数(例如:20
-> 50
, 123
-> 150
).0
表示没有限制。
在获取意思时,将过滤掉月平均搜索量低于所提供数字的意思关键词。0
表示没有过滤器。
在获取意思时,将过滤掉月平均搜索量高于所提供数字的意思关键词。0
表示没有过滤器。
在获取意思时,将过滤掉不属于所提供类别的意思关键词。此处 提供了 .csv
格式的可用类别。
- 必须提供的参数
代码示例
在这个示例中,API 将检索优秀的
餐厅的关键词数据和所有建议的关键词。关键词语言是法文
,地理位置为Paris,Ile-de-France,France
和货币是 EUR
。
JSON cURL Python PHP
Copy curl --user user:pass1 'https://data.oxylabs.io/v1/queries' -H "Content-Type: application/json"
-d '{"source": "google_msv_v2", "query": "meilleur restaurant", "geo_location": "Paris,Ile-de-France,France", "context": [{"key": "language", "value": "french"},{"key": "currency", "value": "EUR"}, {"key": "ideas", "value": true}]}'
# OR if you don't want ideas:
curl --user user:pass1 'https://data.oxylabs.io/v1/queries' -H "Content-Type: application/json"
-d '{"source": "google_msv_v2", "query": "meilleur restaurant", "geo_location": "Paris,Ile-de-France,France", "context": [{"key": "language", "value": "french"},{"key": "currency", "value": "EUR"}, {"key": "ideas", "value": false}]}'
Copy import requests
from pprint import pprint
# Structure payload.
payload = {
'source': 'google_msv_v2',
'query': 'meilleur restaurant',
'geo_location': 'Paris,Ile-de-France,France',
'context': [
{'key': 'language', 'value': 'french'},
{'key': 'currency', 'value': 'EUR'},
{'key': 'ideas', 'value': True}, # OR False if you don't want ideas.
],
}
# Get response.
response = requests.request(
'POST',
'https://data.oxylabs.io/v1/queries',
auth=('user', 'pass1'),
json=payload,
)
# Print prettified response to stdout.
pprint(response.json())
Copy <?php
$params = array(
'source' => 'google_msv_v2',
'query' => 'meilleur restaurant',
'geo_location' => 'Paris,Ile-de-France,France',
'context' => array(
array('key' => 'language', 'value' => 'french'),
array('key' => 'currency', 'value' => 'EUR'),
array('key' => 'ideas', 'value' => true) // or 'value' => false if you don't want ideas
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://data.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
样本输出(历史搜索量条目和意思条目将被剪切):
Copy {
"results": [
{
"content":
{
"ideas": [
{
"cpc": 4.712038,
"keyword": "meilleur restaurant a paris",
"currency": "EUR",
"competition": 0.3385383889238515,
"averageSearchVolume": 1900,
"historicalSearchVolume": [
{
"date": "201803",
"searchVolume": 1600
},
{
"date": "201802",
"searchVolume": 1900
}]
}],
"seeds": [
{
"cpc": 4.05351,
"keyword": "meilleur restaurant",
"currency": "EUR",
"competition": 0.3385341239238515,
"averageSearchVolume": 2900,
"historicalSearchVolume": [
{
"date": "201803",
"searchVolume": 3600
},
{
"date": "201802",
"searchVolume": 2900
}]
}]
}
}]
}
搜寻趋势:探索
google_trends_explore
来源旨在检索 Google 搜寻趋势的结果。
注意: 这个服务能够不断提供结构化数据 - 因此没有必要利用这个来源的解析参数。
查询参数
其结果应符合其地理位置。Google 搜寻趋势:探索,我们接受 2 个字母的 ISO 国家代码作为 geo_location
参数值。我们也允许使用 worldwide
作为 geo_location
的参数值。
让您设置搜索类型(Google Trends GUI 的其中一个选项)。可用值: web_search
, image_search
, google_shopping
, youtube_search
。
日期下限。格式: 年-月-日
。 最早的可能日期: 2004-01-01
。
日期上限。格式:年-月-日
。最早的可能日期: 2004-01-01
。
- 必须提供的参数
代码示例
在这个示例中,我们请求获得 2021 年 1 月 1 日至 2022 年 2 月 2 日之间adidas
搜索词的趋势结果,并将类别设置为“艺术与娱乐”(类别 id:3
)。
JSON cURL Python PHP HTTP
Copy {
"source": "google_trends_explore",
"query": "adidas",
"context": [
{"key": "date_from", "value": "2021-01-01"},
{"key": "date_to", "value": "2022-02-02"},
{"key": "category_id", "value": 3}
]
}
Copy curl --user user:pass1 'https://realtime.oxylabs.io/v1/queries' \
-H "Content-Type: application/json" \
-d '{"source": "google_trends_explore", "query": "adidas", "context": [{"key": "date_from", "value": "2021-01-01"}, {"key": "date_to", "value": "2022-02-02"}, {"key": "category_id", "value": 3}]}'
Copy import requests
from pprint import pprint
# Structure payload.
payload = {
'source': 'google_trends_explore',
'query': 'adidas',
'callback_url': 'https://your.callback.url',
'context': [
{'key': 'date_from', 'value': '2021-01-01'},
{'key': 'date_to', 'value': '2022-02-02'},
{'key': 'category_id', 'value': 3},
],
}
# Get response.
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('user', 'pass1'),
json=payload,
)
# Print prettified response to stdout.
pprint(response.json())
Copy <?php
$params = array(
'source' => 'google_search',
'query' => 'adidas',
'context' => [
[
'key' => 'date_from',
'value' => '2021-01-01'
],
[
'key' => 'date_to',
'value' => '2022-02-02'
],
[
'key' => 'category_id',
'value' => 3
],
]
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
Copy https://realtime.oxylabs.io/v1/queries?source=google_trends_explore&query=adidas&context[0][key]=date_from&context[0][value]=2021-01-01&&context[1][key]=date_to&context[1][value]=2022-02-02&context[2][key]=category_id&context[0][value]=3&access_token=12345abcde
以上示例使用了 Realtime 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。
Last updated 8 months ago