Many websites(mainly search engines) display data based on the geolocation of the incoming request. In such conditions, you can use the geotargeting feature of the API in order to get the perfect data.
cURL Python Nodejs PHP Ruby Java
Copy curl "https://api.scrapingdog.com/scrape?api_key=3e3a09b6ecde9f83856906c5e27dd646&url=http://httpbin.org/ip&country=us"
Copy import requests
url = "https://api.scrapingdog.com/scrape"
params = {
"api_key" : "3e3a09b6ecde9f83856906c5e27dd646" ,
"url" : "http://httpbin.org/ip" ,
"country" : "us"
}
response = requests . get (url, params = params)
print (response.text)
Copy const axios = require ( 'axios' );
const apiUrl = 'https://api.scrapingdog.com/scrape' ;
const apiKey = '3e3a09b6ecde9f83856906c5e27dd646' ;
const targetUrl = 'http://httpbin.org/ip' ;
const country = 'us' ;
axios .get (apiUrl , {
params : {
api_key : apiKey ,
url : targetUrl ,
country : country
}
})
.then (response => {
console .log ( response .data);
})
.catch (error => {
console .error (error);
});
Copy <? php
$apiUrl = 'https://api.scrapingdog.com/scrape' ;
$apiKey = '3e3a09b6ecde9f83856906c5e27dd646' ;
$targetUrl = 'http://httpbin.org/ip' ;
$country = 'us' ;
$ch = curl_init ( $apiUrl . "?api_key=$apiKey&url=$targetUrl&country=$country" ) ;
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true ) ;
$response = curl_exec ( $ch ) ;
if ( curl_errno ( $ch ) ) {
echo 'Error: ' . curl_error ( $ch ) ;
} else {
echo $response;
}
curl_close ( $ch ) ;
?>
Copy require 'rest-client'
api_url = 'https://api.scrapingdog.com/scrape'
api_key = '3e3a09b6ecde9f83856906c5e27dd646'
target_url = 'http://httpbin.org/ip'
country = 'us'
response = RestClient . get(api_url , params: { api_key: api_key , url: target_url , country: country })
puts response . body
Copy import org . apache . http . HttpResponse ;
import org . apache . http . client . HttpClient ;
import org . apache . http . client . methods . HttpGet ;
import org . apache . http . impl . client . HttpClients ;
import java . io . BufferedReader ;
import java . io . InputStreamReader ;
public class CurlToJava {
public static void main ( String [] args) throws Exception {
String apiURL = "https://api.scrapingdog.com/scrape" ;
String apiKey = "3e3a09b6ecde9f83856906c5e27dd646" ;
String targetURL = "http://httpbin.org/ip" ;
String country = "us" ;
HttpClient httpClient = HttpClients . createDefault ();
HttpGet httpGet = new HttpGet(apiURL + "?api_key=" + apiKey + "&url=" + targetURL + "&country=" + country) ;
HttpResponse response = httpClient . execute (httpGet);
BufferedReader reader = new BufferedReader( new InputStreamReader( response . getEntity() . getContent())) ;
String line;
StringBuilder result = new StringBuilder() ;
while ((line = reader . readLine ()) != null ) {
result . append (line);
}
System . out . println ( result . toString ());
}
}