我们可以在 Google 上抓取和解析各种页面类型。您可以向我们提供一个完整的URL 或通过专门建立的页面类型提供一些输入参数(如搜索 ,广告 , 酒店 , 和其他),所以我们可以在我们的终端形成 URL。
注意 :SERP 爬虫 API 在抓取时可以渲染 JavaScript 。这在一些 Google 服务中是有必要的,例如 旅行 。
总览
以下概述我们通过 Google 支持的所有可用数据source
值 。
您可以通过选择菜单右侧的名称跳转至您喜欢的 Google 页面类型。每个页面都包含参数表以及代码示例,可帮助您开始查询。
URL
google
源设计用于检索各种 Google URL 中的内容。这意味着,您可以向我们提供一个转至所需 Google 页面的直接 URL,而不是发送多个参数。我们不会剥离任何参数或以任何其他方式更改您的 URL。
这个数据源也支持解析数据(JSON 格式的结构化数据),只要提交的 URL 用于 Google(SERP 页面)。如果我们不能确认这是一个 SERP 页面请求,我们将返回一个故障信息。
查询参数
- 必须提供的参数
代码示例
在以下示例中,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)。
查询参数
- 必须提供的参数
代码示例
在以下示例中,我们请求从 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.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 搜索结果。
查询参数
- 必须提供的参数
注意 :使用 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 服务的酒店搜索结果。
查询参数
- 必须提供的参数
注意 :请注意,使用 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
参数和包含这些图像的网站的图像相似的图像。
查询参数
- 必须提供的参数
代码示例
在这个示例中,我们请求获得这个图像的反向图像搜索结果: 来自
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 的搜索术语建议。
查询参数
- 必须提供的参数
代码示例
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)。
查询参数
- 必须提供的参数
代码示例
在这个示例中,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 搜寻趋势的结果。
注意: 这个服务能够不断提供结构化数据 - 因此没有必要利用这个来源的解析参数。
查询参数
- 必须提供的参数
代码示例
在这个示例中,我们请求获得 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 集成方法。如果您想在您的查询中使用一些其他集成方法(如推拉 或代理端 点 ),请参考集成方法 部分。