SOCKS5 vs HTTP:哪種代理協議更適合你的業務場景
Choosing between SOCKS5 and HTTP protocols ultimately depends on the specific requirements of your business scenario.
查看全部博客
35M+代理池
99.9%成功率
响應時間<0.5s
無限並發請求
HTTP & SOCKS5
滿足各種需求的代理
LokiProxy專注為您的網路數據項目提供全面支持,助力業務高效運行。
覆蓋3500萬+住宅IP,每次請求自動更換IP,輕鬆應對爬取和數據採集需求。
3500万+住宅IP
>國家/州定位
無限並發會話
粘性/輪換選項
全球動態IP池,無限流量使用,支持粘性和輪換選項,保證高性能連接。
無流量限制
隨機分配國家
專用服務器
可定製帶寬
按 IP 計費,未使用的IP餘額永不過期。通過賬密認證或 IP 白名單輕鬆獲取住宅代理服務。
3500萬+住宅IP
國家/州/城市定位
99.9% 高成功率
會話持續時間可達 24 小時
獨享IP,提供長期穩定的獨享IP地址,適用於電商、社交媒體等場景。
真實住宅IP
100%獨享
高可用性
最长90天续租
依託領先的代理服務,LokiProxy 為用戶提供穩定、可靠、合規的全球代理資源。
1,578,420 IPs
538,330 IPs
442,145 IPs
296,370 IPs
949,015 IPs
426,730 IPs
#include "stdafx.h"
#include "curl/curl.h"
#pragma comment(lib, "libcurl.lib")
static size_t write_buff_data(char *buffer, size_t size, size_t nitems, void *outstream)
{
memcpy(outstream, buffer, nitems * size);
return nitems * size;
}
int GetUrlHTTP(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
// api http
curl_easy_setopt(curl, CURLOPT_PROXY, "http://156.229.21.94:1000");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)buff);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff_data);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 50L);
curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, 2000000L);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (res == CURLE_OK)
{
return res;
}
else
{
printf("%d", res);
}
}
return res;
}
int GetUrlSocks5(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
// api socks5
curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://156.229.21.94:1000");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)buff);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff_data);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 50L);
curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, 2000000L);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (res == CURLE_OK)
{
return res;
}
else
{
printf("%d", res);
}
}
return res;
}
int main()
{
char *buff = (char *)malloc(1024 * 1024);
memset(buff, 0, 1024 * 1024);
GetUrlHTTP("http://ipinfo.io/json", buff);
printf("response: %s", buff);
memset(buff, 0, 1024 * 1024);
GetUrlSocks5("http://ipinfo.io/json", buff);
printf("response: %s", buff);
free(buff);
Sleep(10 * 1000);
return 0; }
package main
import (
"log"
"github.com/go-resty/resty/v2"
)
func main() {
// api socks5
client := resty.New()
client.SetProxy("socks5://156.229.21.94:1000")
response, err := client.R().Get("http://ipinfo.io/json")
if err != nil {
panic(err)
}
log.Println(string(response.Body()))
// api http
client = resty.New()
client.SetProxy("http://156.229.21.94:1000")
response, err = client.R().Get("http://ipinfo.io/json")
if err != nil {
panic(err)
}
log.Println(string(response.Body()))
}
// api http
require("request-promise")({
url: "http://ipinfo.io/json",
proxy: "http://156.229.21.94:1000",
}).then(
function (data) {
console.log(data);
},
function (err) {
console.error(err);
}
);
<?php
// SOCKS5 proxy configuration (NO AUTH)
$proxyHost = '156.229.21.94'; // Proxy host
$proxyPort = '1000'; // Proxy port
// IP info URL
$ipInfoUrl = 'https://ipinfo.io/json';
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $ipInfoUrl); // URL to request
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string
curl_setopt($ch, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort); // Set the SOCKS5 proxy
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); // Set proxy type as SOCKS5 and resolve DNS through proxy
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL peer verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Disable SSL host verification
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); // 30-second connection timeout
curl_setopt($ch, CURLOPT_TIMEOUT, 60); // 60-second total timeout
curl_setopt($ch, CURLOPT_VERBOSE, true); // Enable verbose logging for debugging
// Execute the request
$response = curl_exec($ch);
// Check for cURL errors
if ($response === false) {
echo "cURL Error: " . curl_error($ch) . "";
} else {
echo "Response from IP info:";
echo $response;
}
// Close the cURL session
curl_close($ch);
?>
import java.net.*;
import java.net.http.*;
import java.time.Duration;
public class HttpClientSocksNoAuth {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder()
.proxy(ProxySelector.of(
new InetSocketAddress("156.229.21.94", 1000) // Set the proxy server address and port you extracted
))
.connectTimeout(Duration.ofSeconds(10))
.build();
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://ipinfo.io/json"))
.timeout(Duration.ofSeconds(10))
.header("User-Agent", "Mozilla/5.0")
.GET()
.build();
HttpResponse resp =
client.send(req, HttpResponse.BodyHandlers.ofString());
if (resp.statusCode() == 200) {
System.out.println(resp.body());
} else {
System.err.println("HTTP error: " + resp.statusCode());
}
}
}
# api socks5
import requests
response = requests.get(
"http://ipinfo.io/",
proxies={
"http": "socks5://156.229.21.94:1000",
"https": "socks5://156.229.21.94:1000",
},
)
print(response.text)
# api http
import requests
response = requests.get(
"http://ipinfo.io/",
proxies={
"http": "http://156.229.21.94:1000",
"https": "http://156.229.21.94:1000",
},
)
print(response.text)
全球可信IP資源,確保您的數據採集合法且高效。
專業支持快速響應,解決您的後顧之憂。
輕鬆將我們的高質量代理服務集成並轉售給您的客戶。
輕鬆集成我們的代理服務,快速訪問全球IP資源,滿足各類合規業務需求。
通過合規手段,高效採集公開數據
通過代理抓取網絡趨勢和分析數據
從不同地點監控和評估廣告展示效果
社交媒體帳戶管理、公開內容監測與抓取
精準收集和監控全球電商平臺的數據
即時掌握各平台機票及飯店的更新特價
"loki residential proxies help us effortlessly collect global market data. The connections are stable and fast, significantly improving our data collection efficiency. "
"We need IPs from multiple countries for market research and competitor analysis. loki proxies perfectly meet our needs with accurate and reliable data."
"The best choice for ad verification! High IP purity prevents invalid clicks and ensures our marketing budget is used effectively."
"The API integration is simple and user-friendly, supporting various development environments. Managing IP resources has never been easier, greatly boosting our development efficiency. "
"loki allows us to efficiently manage multiple social media accounts, bypass geographic restrictions, and ensure account security."
"We need real-time monitoring of global flight and hotel prices. loki proxies are fast and stable, with no delays in data acquisition—highly satisfied!"
掌握行業動態,探索高效數據獲取策略,助力您的業務增長。