為什麼選擇無限住宅代理?
購買無限代理
全球IP資源池輕鬆獲取公開數據
dynamic.drive_better
dynamic.drive_better
全場景數據智慧採集
詳細的公共API
我們的代理相容各種代理軟件和熱門程式設計語言,您可以快捷地開展網絡資料獲取工作。
// demo.cpp : Define the entrance for the console application.
//
#include "stdafx.h"
#include "curl/curl.h"
#pragma comment(lib, "libcurl.lib")
//Under the CURLOPT_WRITEFUNCTION setting property, use the callback write_buff_data for processing
static size_t write_buff_data(char *buffer, size_t size, size_t nitems, void *outstream)
{
memcpy(outstream, buffer, nitems*size);
return nitems*size;
}
/*
Use http proxy
*/
int GetUrlHTTP(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_PROXY,"http://proxy host:port");//Set proxy
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)buff);//void* buff will be passed to the fourth parameter of the callback function write_buff_data void* outstream
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff_data);//Under the CURLOPT_WRITEFUNCTION setting property, use the callback write_buff_data for processing
curl_easy_setopt(curl, CURLOPT_URL, url);//Set domain to visit
/* Abort if speed drops below 50 bytes/second for 10 seconds */
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);/*Highest download speed*/
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (res == CURLE_OK){
return res;
}else {
printf("Error code:%d\n", res);
MessageBox(NULL, TEXT("Error in getting IP"), TEXT("assistant"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
/*
Use socks5 proxy
*/
int GetUrlSocks5(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://Proxy host:port");//Set proxy
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);/*Highest download speed*/
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (res == CURLE_OK) {
return res;
}
else {
printf("Error code:%d\n", res);
MessageBox(NULL, TEXT("Error in getting IP"), TEXT("assistant"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
/*
Not use proxy
*/
int GetUrl(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
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);/*Highest download speed*/
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (res == CURLE_OK)
{
return res;
}
else {
printf("Error code:%d\n", res);
MessageBox(NULL, TEXT("Error in getting IP"), TEXT("assistant"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
int main()
{
char *buff=(char*)malloc(1024*1024);
memset(buff, 0, 1024 * 1024);
GetUrl("http://baidu.com", buff);
printf("Not use proxy:%s\n", buff);
memset(buff, 0, 1024 * 1024);
GetUrlHTTP("http://baidu.com", buff);
printf("result of http:%s\n", buff);
memset(buff, 0,1024 * 1024);
GetUrlSocks5("http://baidu.com", buff);
printf("result of socks5:%s\n", buff);
free(buff);
Sleep(10 * 1000);//Wait 10 seconds to exit
return 0;
}
事件
博客新聞
Hong kong xingyun technology limited © Copyright 2024 | blurpath.com.All rights reserved
由於政策原因,本站代理服務不支持在中國大陸使用
隱私政策
服務條款
Cookie協定
退貨政策
dynamic.drive_better
dynamic.drive_better
事件
博客新聞
Hong kong xingyun technology limited © Copyright 2024 | blurpath.com.All rights reserved
由於政策原因,本站代理服務不支持在中國大陸使用
隱私政策
服務條款
Cookie協定
退貨政策