博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
代理IP批量验证程序
阅读量:3532 次
发布时间:2019-05-20

本文共 1674 字,大约阅读时间需要 5 分钟。

#include 
#include
#include
#include
#include
#pragma comment(lib,"wininet.lib") using namespace std;CString content;bool getData(LPCTSTR proxy){ CString data; DWORD dwStatusCode; CInternetSession session("HttpClient"); CHttpFile *pfile = NULL; INTERNET_PROXY_INFO proxyinfo; proxyinfo.dwAccessType = INTERNET_OPEN_TYPE_PROXY; proxyinfo.lpszProxy = proxy; proxyinfo.lpszProxyBypass = NULL; session.SetOption(INTERNET_OPTION_PROXY,(LPVOID)&proxyinfo,sizeof(INTERNET_PROXY_INFO)); session.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 2000); // 2秒的连接超时 session.SetOption(INTERNET_OPTION_SEND_TIMEOUT, 1000); // 1秒的发送超时 session.SetOption(INTERNET_OPTION_RECEIVE_TIMEOUT, 7000); // 7秒的接收超时 session.SetOption(INTERNET_OPTION_DATA_SEND_TIMEOUT, 1000); // 1秒的发送超时 session.SetOption(INTERNET_OPTION_DATA_RECEIVE_TIMEOUT, 7000); // 7秒的接收超时 session.SetOption(INTERNET_OPTION_CONNECT_RETRIES, 1); // 1次重试 try { pfile = (CHttpFile*)session.OpenURL("http://ip.dnsexit.com/", 1, INTERNET_FLAG_TRANSFER_ASCII|INTERNET_FLAG_RELOAD|INTERNET_FLAG_DONT_CACHE); } catch (CInternetException *e) { pfile = NULL; e->Delete(); session.Close(); return false; } pfile->QueryInfoStatusCode(dwStatusCode); if(dwStatusCode == HTTP_STATUS_OK) { while (pfile->ReadString(data)) { content += data; } pfile->Close(); session.Close(); return true; } else { return false; }}int main(){ string line; fstream fin("proxy.txt"); while (getline(fin, line)) { content.Empty(); if (getData(line.c_str())) { cout << content << "is OK!" << endl; } } fin.close(); return 0;}

我们可以利用代理IP来刷访问量等等。

你可能感兴趣的文章