能力值:
( LV2,RANK:10 )
|
-
-
2 楼
The following code example shows how to set proxy data for a LAN connection.
BOOL SetConnectionOptions() { INTERNET_PER_CONN_OPTION_LIST list; BOOL bReturn; DWORD dwBufSize = sizeof(list);
// Fill the list structure. list.dwSize = sizeof(list);
// NULL == LAN, otherwise connectoid name. list.pszConnection = NULL;
// Set three options. list.dwOptionCount = 3; list.pOptions = new INTERNET_PER_CONN_OPTION[3];
// Ensure that the memory was allocated. if(NULL == list.pOptions) { // Return FALSE if the memory wasn't allocated. return FALSE; }
// Set flags. list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS; list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT | PROXY_TYPE_PROXY;
// Set proxy name. list.pOptions[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER; list.pOptions[1].Value.pszValue = "http://proxy:80";
// Set proxy override. list.pOptions[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS; list.pOptions[2].Value.pszValue = "local";
// Set the options on the connection. bReturn = InternetSetOption(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, dwBufSize);
// Free the allocated memory. delete [] list.pOptions;
return bReturn; }
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
层主的函数是设置IE LAN连接代理
调用之后打开IE是以代理访问网页
但是我程序里面依然出现验证码说明访问网页依然是以本地IP访问
BOOL SetConnectionOptions()
{
INTERNET_PER_CONN_OPTION_LIST list;
BOOL bReturn;
DWORD dwBufSize = sizeof(list);
// Fill the list structure.
list.dwSize = sizeof(list);
// NULL == LAN, otherwise connectoid name.
list.pszConnection = NULL;
// Set three options.
list.dwOptionCount = 3;
list.pOptions = new INTERNET_PER_CONN_OPTION[3];
// Ensure that the memory was allocated.
if(NULL == list.pOptions)
{
// Return FALSE if the memory wasn't allocated.
return FALSE;
}
// Set flags.
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT |
PROXY_TYPE_PROXY;
// Set proxy name.
list.pOptions[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[1].Value.pszValue = "118.244.147.49:8080";
// Set proxy override.
list.pOptions[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
list.pOptions[2].Value.pszValue = "local";
// Set the options on the connection.
bReturn = InternetSetOption(NULL,
INTERNET_OPTION_PER_CONNECTION_OPTION, &list, dwBufSize);
// Free the allocated memory.
delete [] list.pOptions;
return bReturn;
}
char* DownLoads(char* pszURL)
{
SetConnectionOptions();
HINTERNET Handle =InternetOpenA("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; InfoPath.2; .NET CLR 2.0.50727; MS-RTC LM 8; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)",1,0,0,0);
DWORD dwContext[]={0,0,0};
char* pszVerb ="GET";
char* pszVersion ="HTTP/1.1";
char *szBuffer= new char[4095];
DWORD dwNumberOfBytesRead;
memset(szBuffer,0,4095);
HINTERNET hURL =InternetConnectA(Handle,"cas.sdo.com",0x1BB,0,0,3,0,(DWORD_PTR)dwContext);
if (hURL == NULL)
{
MessageBoxA(0,"InternetConnect出错",0,0);
return 0;
}
Handle =HttpOpenRequestA(hURL,pszVerb,pszURL,pszVersion,0,0,0x80803000,(DWORD_PTR)dwContext);
if (HttpSendRequestW(Handle,0,0,pszVersion,0) ==NULL)
{
MessageBoxA(0,"出现错误 HttpSendRequest",0,0);
return 0;
}
InternetReadFile(Handle,szBuffer,4095,&dwNumberOfBytesRead);
return szBuffer;
}
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
你确定验证码的机制是因为同IP?
你多次同一个代理?
你用代理打开ip138不就知道有没有代理成功了呗。这么简单的道理
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
确定验证码的机制是因为同IP
没有 多次同一个代理
是我哪里出错了 即使我设置:
list.pOptions[1].Value.pszValue = "1.1.1.1:9999";
我代码依然可以访问网页
|
能力值:
( LV2,RANK:10 )
|
-
-
6 楼
[QUOTE=伏特加;1292382]确定验证码的机制是因为同IP
没有 多次同一个代理
是我哪里出错了 即使我设置:
list.pOptions[1].Value.pszValue = "1.1.1.1:9999";
我代码依然可以访问网页[/QUOTE]
我说了啊。 你打开138看看呗。 有没有代理成功。这种明显是没有代理成功。
|
能力值:
( LV2,RANK:10 )
|
-
-
7 楼
既然IP是1.1.1.1依然可以访问网页了 是我的代码有误
|
能力值:
( LV2,RANK:10 )
|
-
-
8 楼
可能是异步的问题?
HINTERNET Handle =InternetOpenA("icrosoft Internet Explorer",0,0,0,0);
if (Handle == NULL)
{
return NULL;
}
if (InternetSetOptionA(Handle,6,(LPVOID)&Option,4) == NULL)
{
return NULL;
}
HINTERNET hUrl =InternetOpenUrlA(Handle,strUrl,0,0,0,0);
if (HttpQueryInfoA(hUrl,0X13,lpInfoBuf,&dwBufLenth,0) == NULL)
{
return NULL;
}
InternetReadFile(hUrl,PackBuffer,9000,&dwBufLenth);
HINTERNET Handle =InternetOpenA("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; InfoPath.2; .NET CLR 2.0.50727; MS-RTC LM 8; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)",1,0,0,0);
DWORD Option =0x2710;
DWORD dwContext[]={0x274,0x278,0x27C};
char* pszVerb ="GET";
char* pszVersion ="HTTP/1.1";
char *szBuffer= new char[4095];
DWORD dwNumberOfBytesRead;
memset(szBuffer,0,4095);
InternetSetOptionA(Handle,6,(LPVOID)&Option,4);
HINTERNET hURL =InternetConnectA(Handle,"127.0.0.1",0x1BB,0,0,3,0,(DWORD_PTR)dwContext);
if (hURL == NULL)
{
MessageBoxA(0,"InternetConnect出错",0,0);
return 0;
}
Handle =HttpOpenRequestA(hURL,pszVerb,pszURL,pszVersion,0,0,0x80803000,(DWORD_PTR)dwContext);
if (HttpSendRequestW(Handle,0,0,pszVersion,0) ==NULL)
{
MessageBoxA(0,"出现错误 HttpSendRequest",0,0);
return 0;
}
InternetReadFile(Handle,szBuffer,4095,&dwNumberOfBytesRead);
|