API集成集成

SUGGEST EDITS
– If you haven't used proxies before, you'll find this easier.
– 100% success rate plus accurate data
– Data sources: direct; search; ads; images, suggestions, shopping prod; product pricing; hotels...
– Requires an open connection in order to send the acquired results.
– Single query – no batches
– Supports any SERP keyword
– Parsing: raw HTML, and in most cases – structured JSON.

HTTP请求地址:POST scrape.smartproxy.com/v1/tasks

https://scrape.smartproxy.com/v1/tasks?target=google_search&query=world&domain=com&access_token=pass2021
curl -u username:password 'https://scrape.smartproxy.com/v1/tasks' -H "Content-Type: application/json" -d '{"target": "google_search", "domain": "com", "query": "world"}'
<?php 

$username = "SPusername";
$password = "SPpassword";

$search = [
    'target' => 'google_search',
    'domain' => 'com',
    'query' => 'world',
    'parse' => true
];

$ch = curl_init();

$headers[] = 'Content-Type: application/json';

$options = [
   CURLOPT_URL => 'https://scrape.smartproxy.com/v1/tasks',
   CURLOPT_USERPWD => sprintf('%s:%s', $username, $password),
   CURLOPT_POSTFIELDS => json_encode($search),
   CURLOPT_RETURNTRANSFER => 1,
   CURLOPT_ENCODING => 'gzip, deflate',
   CURLOPT_HTTPHEADER => $headers,
   CURLOPT_SSL_VERIFYPEER => false,
   CURLOPT_SSL_VERIFYHOST => false
];
curl_setopt_array($ch, $options);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

$result = json_decode($result);
var_dump($result);

 ?>
import requests

headers = {
    'Content-Type': 'application/json'
}

task_params = {
    'target': 'google_search',
    'domain': 'com',
    'query': 'world',
    'parse': True
}

username = 'SPuserame'
password = 'SPpassword'
  
response = requests.post(
    'https://scrape.smartproxy.com/v1/tasks',
    headers = headers,
    json = task_params,
    auth = (username, password)
)
print(response.json)