提出请求
基本查詢
基本查詢僅需要輸入USERNAME
和PASSWORD
,無需其他任何參數。對於基本查詢,是通過隨機IP地址發送請求,每次新請求都會使用不同的代理。。
代碼示例:
在下方範例中,通過隨機IP執行對ipinfo.thordata.com
的查詢。
curl -x "https://td-customer-USERNAME:[email protected]:9999" "https://ipinfo.thordata.com"
using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
class csharp_https
{
static void Main(string[] args)
{
Task t = new Task(DownloadPageAsync);
t.Start();
Console.ReadLine();
}
static async void DownloadPageAsync()
{
string page = "https://ipinfo.thordata.com";
var proxy = new WebProxy("https://t.pr.thordata.net:9999")
{
UseDefaultCredentials = false,
Credentials = new NetworkCredential(
userName: "td-customer-USERNAME",
password: "PASSWORD")
};
var httpClientHandler = new HttpClientHandler()
{
Proxy = proxy,
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
};
var client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
var response = await client.GetAsync(page);
using (HttpContent content = response.Content)
{
string result = await content.ReadAsStringAsync();
Console.WriteLine(result);
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
)
const (
resourceUrl = "https://ipinfo.thordata.com"
proxyHost = "t.pr.thordata.net:9999"
username = "td-customer-USERNAME"
password = "PASSWORD"
)
func main() {
proxyUrl := &url.URL{
Scheme: "https",
User: url.UserPassword(username, password),
Host: proxyHost,
}
client := http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxyUrl),
},
}
resp, err := client.Get(resourceUrl)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
bodyString := string(body)
fmt.Println(bodyString)
}
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
public class JavaHttps {
public static final String username = "td-customer-USERNAME";
public static final String password = "PASSWORD";
public static final int port = 9999;
public static final String proxyHost = "t.pr.thordata.net";
public CloseableHttpClient client;
public JavaHttps() {
HttpHost proxy = new HttpHost(proxyHost, port, "https");
CredentialsProvider cred_provider = new BasicCredentialsProvider();
cred_provider.setCredentials(new AuthScope(proxy),
new UsernamePasswordCredentials(username, password));
client = HttpClients.custom()
.setConnectionManager(new BasicHttpClientConnectionManager())
.setProxy(proxy)
.setDefaultCredentialsProvider(cred_provider)
.build();
}
public String request(String url) throws IOException {
HttpGet request = new HttpGet(url);
CloseableHttpResponse response = client.execute(request);
try {
return EntityUtils.toString(response.getEntity());
} finally { response.close(); }
}
public void close() throws IOException { client.close(); }
public static void main(String[] args) throws IOException {
JavaHttps client = new JavaHttps();
try {
System.out.println(client.request("https://ipinfo.thordata.com"));
} finally { client.close(); }
}
}
<?php
$url = 'http://ipinfo.thordata.com';
$proxy = 't.pr.thordata.net';
$port = 9999;
$user = 'td-customer-USERNAME';
$psw = 'PASSWORD';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, "$proxy:$port");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "$user:$psw");
$result = curl_exec($ch);
curl_close($ch);
if ($result)
{
echo $result . PHP_EOL;
}
?>
import requests
username = "td-customer-USERNAME"
password = "PASWORD"
proxy_server = "t.pr.thordata.net:9999"
proxies = {"https": f"https://{username}:{password}@{proxy_server}"}
response = requests.get("https://ipinfo.thordata.com", proxies=proxies)
print(response.text)
const rp = require('request-promise');
const username = "td-customer-USERNAME";
const password = "PASSWORD";
const proxyServer = "t.pr.thordata.net:9999";
rp({
url: 'https://ipinfo.thordata.com',
proxy: `https://${username}:${password}@${proxyServer}`,
})
.then(function(data) {
console.log(data);
})
.catch(function(err) {
console.error(err);
});
require "uri"
require 'net/http'
require 'openssl'
proxy_host = 't.pr.thordata.net'
proxy_port = 9999
proxy_user = 'td-customer-USERNAME'
proxy_pass = 'PASSWORD'
uri = URI.parse('https://ipinfo.thordata.com')
proxy = Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass)
req = Net::HTTP::Get.new(uri)
result = proxy.start(uri.host, uri.port, use_ssl: true, ssl_version: :TLSv1_2) do |http|
http.request(req)
end
puts result.body
特定請求
Thordata支持在用戶名中添加定位與會話參數,以指定代理的國家、州、城市來源或控制會話行為。
代碼示例:
使用來自澳大利亞墨爾本的代理,並設置 10 分鐘的粘性會話:
curl -x "http://td-customer-USERNAME-country-au-state-victoria-city-melbourne-sessid-au123-sesstime-10:[email protected]:9999" "https://ipinfo.thordata.com"
查詢參數
username
代理賬戶用戶名
td-customer-username
continent
大洲,隨機地區無此參數。
continent-asia
country
完整的國家/地區名,隨機地區無此參數
country-au(2 個字母的國家代碼
state
州,隨機地區無此參數
state-victoria
city
您要指定的城市。可不帶“state”參數使用。
city-melbourne
session
粘性 IP 和IP 所需。在固定 IP 或切換時查找特定 IP 時使用它。
sessid-au123456
sessTime
與會話一起使用來設定 IP 持續時間,最長時間為 90分鐘。
sessTime-5
password
代理賬戶密碼
password
asn
指定國家的ISP運營商,隨機無此參數
asn-AS1221
Last updated
Was this helpful?