Google 可以使用多个不同的目标进行抓取,包括 Google 搜索栏、直接 URL 或更具体的目标,例如 Google 建议、Google 广告等。下面你将找到每个目标,是否可以解析为 JSON,其所需的参数,以及 cURL、Python 和 PHP 的现成代码示例,你只需更改 SERP 抓取 API 的用户名和密码 用户让代码正常工作。有关可用参数,请参阅参数
google_search
可解析:是
必需参数:query(本例中为history)
可选参数: domain, page_from, num_pages, locale, geo, device_type, parse, google_results_language, google_tbm, google_tbs, google_safe_search, session_id
通过向查询参数提供你的查询来检索 Google 搜索引擎结果页面。
curl -u SPusername:SPpassword -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"target\": \"google_search\", \"query\": \"history\", \"parse\": \"true\", \"geo\": \"London,England,United Kingdom\"}"
import requests
task_params = {
'target': 'google_search',
'query': 'history',
'parse': True,
'geo': 'London,England,United Kingdom'
}
username = 'SPusername'
password = 'SPpassword'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'target' => 'google_search',
'query' => 'history',
'parse' => True,
'geo' => 'London,England,United Kingdom'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'SPusername' . ':' . 'SPpassword');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$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);
?>
上面代码的结果和截图:
"organic": [
{
"pos": 1,
"url": "https://myactivity.google.com/",
"desc": "Welcome to My Activity. Data helps make Google services more useful for you. Sign in to review and manage your activity, including things you've searched ...",
"title": "Welcome to My Activity",
"sitelinks": {
"expanded": [
{
"url": "https://support.google.com/accounts/answer/7028918?hl=en&co=GENIE.Platform%3DAndroid",
"title": "Android - Google Account Help"
},
{
"url": "https://myactivity.google.com/lite",
"title": "Use your Google Account"
}
]
},
"url_shown": "https://myactivity.google.com",
"pos_overall": 1
},
{
"pos": 2,
"url": "https://en.wikipedia.org/wiki/History",
"desc": "History (from Greek ἱστορία, historia, meaning \"inquiry; knowledge acquired by investigation\") is the study and the documentation of the past.",
"title": "History - Wikipedia",
"url_shown": "https://en.wikipedia.org› wiki › History",
"pos_overall": 11
}
{
"results": [
{
"content": {
"url": "https://www.google.com/search?q=history&lr=lang_en&nfpr=1&hl=en",
"page": 1,
"results": {
"paid": [],
"videos": [
{
"url": "https://www.youtube.com/watch?v=gajqdrpNeHE",
"title": "History of London",
"author": "New London Architecture",
"source": "3 Aug 2015",
"key_moments": [
{
"desc": "History of London",
"timestamp": "00:12"
},
{
"desc": "Medieval City of London",
"timestamp": "01:18"
},
{
"desc": "Georgian London",
"timestamp": "02:12"
},
{
"desc": "The 19th Century",
"timestamp": "02:21"
}
],
"pos_overall": 8
},
{
"url": "https://www.youtube.com/watch?v=hRVfCplkKq4",
"title": "Olivia Holt - History (Official Video)",
"author": "OliviaHoltVEVO",
"source": "21 Nov 2016",
"pos_overall": 9
},
{
"url": "https://www.youtube.com/watch?v=BeoZHGn8_HA",
"title": "The history of the Red Army (2/2) | DW Documentary",
"author": "DW Documentary",
"source": "2 days ago",
"pos_overall": 10
}
],
"organic": [
{
"pos": 1,
"url": "https://myactivity.google.com/",
"desc": "Welcome to My Activity. Data helps make Google services more useful for you. Sign in to review and manage your activity, including things you've searched ...",
"title": "Welcome to My Activity",
"sitelinks": {
"expanded": [
{
"url": "https://support.google.com/accounts/answer/7028918?hl=en&co=GENIE.Platform%3DAndroid",
"title": "Android - Google Account Help"
},
{
"url": "https://myactivity.google.com/lite",
"title": "Use your Google Account"
}
]
},
"url_shown": "https://myactivity.google.com",
"pos_overall": 1
},
{
"pos": 2,
"url": "https://en.wikipedia.org/wiki/History",
"desc": "History (from Greek ἱστορία, historia, meaning \"inquiry; knowledge acquired by investigation\") is the study and the documentation of the past.",
"title": "History - Wikipedia",
"url_shown": "https://en.wikipedia.org› wiki › History",
"pos_overall": 11
},
{
"pos": 3,
"url": "https://www.history.co.uk/",
"desc": "Find out more about the shows on Sky HISTORY's TV channel, with plenty to read and watch on your favourite historical topics.",
"title": "Homepage | Sky HISTORY UK TV Channel",
"url_shown": "https://www.history.co.uk",
"pos_overall": 12
},
{
"pos": 4,
"url": "https://support.google.com/chrome/answer/95589?hl=en-GB&co=GENIE.Platform%3DAndroid",
"desc": "At the top right, tap More More and then History. If your address bar is at the bottom, swipe up on the address bar. Tap History History · To visit a site, tap ...",
"title": "View and delete your Chrome browsing history - Android",
"url_shown": "https://support.google.com› chrome › answer",
"pos_overall": 13
},
{
"pos": 5,
"url": "https://www.nhm.ac.uk/",
"desc": "Book tickets. Explore our galleries, science, news, videos and amazing images. South Kensington Tube. London, UK.",
"title": "Natural History Museum: Home",
"url_shown": "https://www.nhm.ac.uk",
"pos_overall": 14
},
{
"pos": 6,
"url": "https://www.history.ac.uk/",
"desc": "The Institute of Historical Research is the UK's national centre for history, dedicated to supporting historians of all kinds. 2021 is the centenary of the ...",
"title": "Institute of Historical Research",
"url_shown": "https://www.history.ac.uk",
"pos_overall": 15
},
{
"pos": 7,
"url": "https://www.historytoday.com/",
"desc": "History Today is the world's leading serious history magazine. Read our monthly articles, features and reviews. Subscriptions to print, archive and digital ...",
"title": "History Today | The World's Leading Serious History Magazine",
"url_shown": "https://www.historytoday.com",
"pos_overall": 16
}
],
"twitter": [
{
"pos": 1,
"url": "https://twitter.com/HISTORY",
"title": "",
"tweets": [
{
"url": "https://twitter.com/HISTORY/status/1518400147067076608?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Etweet",
"content": "How it started vs. How it's going",
"timeframe": "9 hours ago"
},
{
"url": "https://twitter.com/HISTORY/status/1518349252853788672?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Etweet",
"content": "We're getting hungry! \nDon't miss a delicious new episode of The Food That Built America, TONIGHT at 9/8c",
"timeframe": "13 hours ago"
},
{
"url": "https://twitter.com/HISTORY/status/1518245939953094656?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Etweet",
"content": "The Library of Congress was established on #ThisDayInHistory in 1800 when President John Adams approved legislation appropriating $5,000 to purchase “such books as may be necessary for the use of Congress.” www.history.com/topics/…",
"timeframe": "20 hours ago"
}
],
"pos_overall": 6
}
],
"instant_answers": [
{
"type": "unknown",
"_parsed": false,
"pos_overall": 7
}
],
"related_searches": {
"pos_overall": 20,
"related_searches": [
"my history",
"history google",
"search history",
"delete history",
"history chrome",
"history of the world",
"history youtube"
]
},
"related_questions": [
{
"pos": 1,
"search": {
"url": "/search?lr=lang_en&nfpr=1&hl=en&q=How+do+I+see+all+my+history%3F&sa=X&ved=2ahUKEwiA563JhK_3AhWGGLkGHV8jAdgQzmd6BAgeEAU",
"title": "How do I see all my history?"
},
"source": {
"url": "https://support.google.com/chrome/answer/95589?hl=en&co=GENIE.Platform%3DAndroid",
"title": "View & delete your Chrome browsing history - Android - Google Support",
"url_shown": "https://support.google.com › chrome › answer"
},
"question": "How do I see all my history?",
"pos_overall": 2
},
{
"pos": 2,
"search": {
"url": "/search?lr=lang_en&nfpr=1&hl=en&q=How+can+I+delete+history%3F&sa=X&ved=2ahUKEwiA563JhK_3AhWGGLkGHV8jAdgQzmd6BAgbEAU",
"title": "How can I delete history?"
},
"source": {
"url": "https://support.google.com/chrome/answer/95589?hl=en&co=GENIE.Platform%3DDesktop",
"title": "View & delete your Chrome browsing history - Computer - Google Help",
"url_shown": "https://support.google.com › chrome › answer"
},
"question": "How can I delete history?",
"pos_overall": 3
},
{
"pos": 3,
"answer": "On the left navigation panel, click Data & privacy. Under \"History settings,\" click My Activity. To view your activity: Browse your activity, organized by day and time.",
"search": {
"url": "/search?lr=lang_en&nfpr=1&hl=en&q=Can+I+see+my+Google+search+history%3F&sa=X&ved=2ahUKEwiA563JhK_3AhWGGLkGHV8jAdgQzmd6BAgdEAU",
"title": "Can I see my Google search history?"
},
"source": {
"url": "https://support.google.com/accounts/answer/7028918?hl=en&co=GENIE.Platform%3DDesktop",
"title": "View & control activity in your account - Computer - Google Support",
"url_shown": "https://support.google.com › accounts › answer"
},
"question": "Can I see my Google search history?",
"pos_overall": 4
},
{
"pos": 4,
"answer": "In any Chrome window, use the keyboard shortcut Ctrl+H, or navigate to the URL chrome://history . Or, click the Menu button, which is located near the top-right side of the browser window, and choose History, then History again.22 May 2017",
"search": {
"url": "/search?lr=lang_en&nfpr=1&hl=en&q=Can+I+see+my+history%3F&sa=X&ved=2ahUKEwiA563JhK_3AhWGGLkGHV8jAdgQzmd6BAgcEAU",
"title": "Can I see my history?"
},
"source": {
"url": "https://www.telegraph.co.uk/technology/0/view-delete-browser-history/",
"title": "How to view and delete your browser history - The Telegraph",
"url_shown": "https://www.telegraph.co.uk › technology › view-delete-b..."
},
"question": "Can I see my history?",
"pos_overall": 5
}
],
"search_information": {
"query": "history",
"showing_results_for": "history",
"total_results_count": 5260000000
},
"total_results_count": 5260000000,
"related_searches_categorized": [
{
"category": {
"name": "Browser history",
"type": "collapsed"
},
"pos_overall": 17
},
{
"category": {
"name": "Types of history",
"type": "collapsed"
},
"pos_overall": 18
},
{
"category": {
"name": "History and historian",
"type": "collapsed"
},
"pos_overall": 19
}
]
},
"last_visible_page": 10,
"parse_status_code": 12000
},
"url": "https://www.google.com/search?q=history&lr=lang_en&nfpr=1&hl=en",
"task_id": "6924307569175454721",
"created_at": "2022-04-25 10:46:11",
"updated_at": "2022-04-25 10:46:19"
}
]
}
google
可解析:是
必需参数: url
可选参数: geo, device_type, parse, session_id
通过向 url 参数提供完整的 Google URL 来检索 Google 搜索引擎结果页面。在这种情况下,可以在 URL 本身中指定其他参数
curl -u SPusername:SPpassword -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"target\": \"google\", \"url\": \"https://www.google.com/search?q=history\", \"parse\": \"true\"}"
import requests
task_params = {
'target': 'google',
'url': 'https://www.google.com/search?q=history',
'parse': True,
}
username = 'SPusername'
password = 'SPpassword'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'target' => 'google',
'url' => 'https://www.google.com/search?q=history',
'parse' => True
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'SPusername' . ':' . 'SPpassword');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$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);
?>
google_hotels
可解析: 否
必需参数: query
可选参数: guests, date_range, domain, page_from, num_pages, locale, geo, device_type, google_results_language, session_id
检索 Google 酒店 搜索结果。对于此目标,你需要在查询中包含“酒店”一词,可以是英语或当地语言
curl -u SPusername:SPpassword -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"target\": \"google_hotels\", \"query\": \"hilton\", \"parse\": \"False\", \"geo\": \"London,England,United Kingdom\"}"
import requests
task_params = {
'target': 'google_hotels',
'query': 'hilton',
'parse': False,
'geo': 'London,England,United Kingdom'
}
username = 'SPusername'
password = 'SPpassword'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'target' => 'google_hotels',
'query' => 'hilton',
'parse' => False,
'geo' => 'London,England,United Kingdom'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'SPusername' . ':' . 'SPpassword');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$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);
?>
google_travel_hotels
可解析: 否
必需参数: query
可选参数: domain, page_from, locale, geo, device_type, stars: [3, 4], guests: "2", date_range: "2022-11-10,2022-11-20", session_id
检索 Google 旅行 服务的酒店搜索结果。
curl -u SPusername:SPpassword -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"target\": \"google_travel_hotels\", \"query\": \"hilton\", \"parse\": \"False\", \"geo\": \"London,England,United Kingdom\"}"
import requests
task_params = {
'target': 'google_travel_hotels',
'query': 'hilton',
'parse': False,
'geo': 'London,England,United Kingdom'
}
username = 'SPusername'
password = 'SPpassword'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'target' => 'google_travel_hotels',
'query' => 'hilton',
'parse' => False,
'geo' => 'London,England,United Kingdom'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'SPusername' . ':' . 'SPpassword');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$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);
?>
google_shopping_search
可解析: 是
必需参数: query
可选参数: domain, page_from, num_pages, locale, geo, device_type, parse, session_id
通过向查询参数提供你的查询来检索 Google 购物 搜索结果页面。
curl -u SPusername:SPpassword -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"target\": \"google_shopping_search\", \"query\": \"sneakers\", \"parse\": \"true\", \"geo\": \"London,England,United Kingdom\"}"
import requests
task_params = {
'target': 'google_shopping_search',
'query': 'sneakers',
'parse': True,
'geo': 'London,England,United Kingdom'
}
username = 'SPusername'
password = 'SPpassword'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'target' => 'google_shopping_search',
'query' => 'sneakers',
'parse' => True,
'geo' => 'London,England,United Kingdom'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'SPusername' . ':' . 'SPpassword');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$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);
?>
google_shopping_product
可解析: 是
必需参数: query (as item ID from Google Shopping)
可选参数: domain, locale, geo, device_type, parse, google_results_language, session_id
使用提供给查询参数的商品 ID 检索 Google 购物* 搜索结果
curl -u SPusername:SPpassword -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"target\": \"google_shopping_product\", \"query\": \"8129397700139936548\", \"parse\": \"true\", \"geo\": \"London,England,United Kingdom\"}"
import requests
task_params = {
'target': 'google_shopping_product',
'query': '8129397700139936548',
'parse': True,
'geo': 'London,England,United Kingdom'
}
username = 'SPusername'
password = 'SPpassword'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'target' => 'google_shopping_product',
'query' => '8129397700139936548',
'parse' => True,
'geo' => 'London,England,United Kingdom'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'SPusername' . ':' . 'SPpassword');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$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);
?>
google_shopping_pricing
可解析: 是
必需参数: query (as item ID from Google Shopping)
可选参数: domain, page_from, locale, geo, device_type, parse, google_results_language, session_id
通过向查询参数提供产品 ID,检索包含特定商品优惠的 Google 购物* 页面结果。
curl -u SPusername:SPpassword -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"target\": \"google_shopping_pricing\", \"query\": \"1487724521556311753\", \"parse\": \"true\", \"geo\": \"London,England,United Kingdom\"}"
import requests
task_params = {
'target': 'google_shopping_pricing',
'query': '1487724521556311753',
'parse': True,
'geo': 'London,England,United Kingdom'
}
username = 'SPusername'
password = 'SPpassword'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'target' => 'google_shopping_pricing',
'query' => '1487724521556311753',
'parse' => True,
'geo' => 'London,England,United Kingdom'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'SPusername' . ':' . 'SPpassword');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$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);
?>
google_images
可解析: 否
必需参数: query
可选参数: domain, page_from, locale, geo, device_type, google_results_language, session_id
检索与你从 Google图片 搜索页面提供的图像链接类似的图像链接。
curl -u SPusername:SPpassword -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"target\": \"google_images\", \"query\": \"https://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg\", \"parse\": \"False\", \"geo\": \"London,England,United Kingdom\"}"
import requests
task_params = {
'target': 'google_images',
'query': 'https://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg',
'parse': False,
'geo': 'London,England,United Kingdom'
}
username = 'SPusername'
password = 'SPpassword'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'target' => 'google_images',
'query' => 'https://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg',
'parse' => False,
'geo' => 'London,England,United Kingdom'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'SPusername' . ':' . 'SPpassword');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$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);
?>
google_suggest
可解析: 否 (已返回结构化数据)
必需参数: query, ISO 2 格式的 geo
可选参数: locale, geo, device_type, session_id
检索 Google 搜索词建议。
curl -u SPusername:SPpassword -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"target\": \"google_suggest\", \"query\": \"world\", \"parse\": \"False\"}"
import requests
task_params = {
'target': 'google_suggest',
'query': 'world',
'parse': False
}
username = 'SPusername'
password = 'SPpassword'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'target' => 'google_suggest',
'query' => 'world',
'parse' => False
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'SPusername' . ':' . 'SPpassword');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$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);
?>
google_ads
可解析: 是
必需参数: query
可选参数: domain, page_from, num_pages, locale, geo, device_type, parse, google_results_language, google_tbm, google_tbs, session_id
如果可能的话,检索带有付费广告的 Google 搜索结果(并非所有响应都包含广告)。
curl -u SPusername:SPpassword -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"target\": \"google_ads\", \"query\": \"sneakers\", \"parse\": \"true\", \"geo\": \"London,England,United Kingdom\"}"
import requests
task_params = {
'target': 'google_ads',
'query': 'sneakers',
'parse': True,
'geo': 'London,England,United Kingdom'
}
username = 'SPusername'
password = 'SPpassword'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'target' => 'google_ads',
'query' => 'sneakers',
'parse' => True,
'geo' => 'London,England,United Kingdom'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'SPsupport' . ':' . 'SPpassword');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$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);
?>
google_trends_explore
可解析: 否 (已返回结构化数据)
必需参数: query
可选参数: search_type, date_start, date_end, geo, device_type, session_id
检索 Google 趋势 结果。该目标返回结构化数据,因此无需使用解析参数。
Updated 9 months ago