To get a proxy from a specific US state, add the st
flag to the authorization string. For example, us_california
, us_illinois
. Click here for a complete list of US states.
Here are a few examples of valid combinations of state
parameters:
st-us_california-city-los_angeles
st-us_illinois-city-springfield
st-us_michigan-city-detroit
st-us_ohio-city-columbus
st-us_maine-city-portland
st-us_tennessee-city-memphis
Code example
In this example, a query to ip.oxylabs.io/location
is performed from a random IP address from California, USA:
cURL PHP Python Java C# Ruby
Copy curl -x pr.oxylabs.io:7777 -U "customer-USERNAME-st-us_california:PASSWORD" https://ip.oxylabs.io/location
Copy <? php
$username = 'USERNAME' ;
$password = 'PASSWORD' ;
$state = 'us_california' ;
$proxy = 'pr.oxylabs.io:7777' ;
$query = curl_init ( 'https://ip.oxylabs.io/location' ) ;
curl_setopt ( $query , CURLOPT_RETURNTRANSFER , 1 ) ;
curl_setopt ( $query , CURLOPT_PROXY , "http://$proxy" ) ;
curl_setopt ( $query , CURLOPT_PROXYUSERPWD , "customer-$username-st-$state:$password" ) ;
$output = curl_exec ( $query ) ;
curl_close ( $query ) ;
if ($output)
echo $output;
?>
Copy import urllib . request
import random
username = 'USERNAME'
password = 'PASSWORD'
state = 'us_california'
entry = ( 'http://customer- %s -st- %s : %s @pr.oxylabs.io:7777' %
(username , state , password))
query = urllib . request . ProxyHandler ({
'http' : entry,
'https' : entry,
})
execute = urllib . request . build_opener (query)
print (execute. open ( 'https://ip.oxylabs.io/location' ). read ())
Copy package example ;
import org . apache . http . HttpHost ;
import org . apache . http . client . fluent . * ;
public class Example {
public static void main ( String [] args) throws Exception {
HttpHost entry = new HttpHost( "pr.oxylabs.io" , 7777 ) ;
String query = Executor . newInstance ()
. auth (entry , "customer-USERNAME-st-us_california" , "PASS" )
. execute ( Request . Get ( "http://ip.oxylabs.io/location" ) . viaProxy (entry))
. returnContent () . asString ();
System . out . println (query);
}
}
Copy using System ;
using System . Net ;
class Example
{
static void Main ()
{
var client = new WebClient ();
client . Proxy = new WebProxy ( "pr.oxylabs.io:7777" );
client . Proxy . Credentials = new NetworkCredential ( "customer-USERNAME-st-us_california" , "PASSWORD" );
Console . WriteLine ( client . DownloadString ( "https://ip.oxylabs.io/location" ));
}
}
Copy require 'uri'
require 'net/http'
uri = URI . parse( 'https://ip.oxylabs.io/location' )
proxy = Net :: HTTP :: Proxy ( 'pr.oxylabs.io' , 7777 , 'customer-USERNAME-st-us_california' , 'PASSWORD' )
req = Net :: HTTP :: Get . new (uri . path)
result = proxy . start(uri . host , uri . port) do | http |
http . request(req)
end
Find the complete list of US states by clicking the file below:
Last updated 4 months ago