首页
社区
课程
招聘
[求助]用Internet函数访问网站设置代理 求助
发表于: 2014-6-11 16:40 6900

[求助]用Internet函数访问网站设置代理 求助

2014-6-11 16:40
6900
HINTERNET Handle =InternetOpenA("DoInternetProxy",INTERNET_OPEN_TYPE_PROXY,0,0,0);

        INTERNET_PROXY_INFO ProxyInfo = {0};

        ProxyInfo.dwAccessType = INTERNET_OPEN_TYPE_PROXY;

        ProxyInfo.lpszProxy = "http=http://59.36.74.28:9999";

        ProxyInfo.lpszProxyBypass = NULL;

        InternetSetOption(Handle, INTERNET_OPTION_PROXY, &ProxyInfo, sizeof(ProxyInfo));

我想往网站上下载一些内容,频繁的话会出现验证码 以上这样设置过后还是出现验证码 证明我写的不对 参考了好多资料了 都是这么写的 我错在哪里了 求助!

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (7)
雪    币: 185
活跃值: (25)
能力值: ( 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;
}
2014-6-11 16:51
0
雪    币: 100
活跃值: (10)
能力值: ( 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;

}
上传的附件:
2014-6-11 17:17
0
雪    币: 185
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
你确定验证码的机制是因为同IP?

你多次同一个代理?

你用代理打开ip138不就知道有没有代理成功了呗。这么简单的道理
2014-6-11 17:54
0
雪    币: 100
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
确定验证码的机制是因为同IP

没有 多次同一个代理

是我哪里出错了 即使我设置:
list.pOptions[1].Value.pszValue = "1.1.1.1:9999";

我代码依然可以访问网页
2014-6-11 18:11
0
雪    币: 185
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
[QUOTE=伏特加;1292382]确定验证码的机制是因为同IP

没有 多次同一个代理

是我哪里出错了 即使我设置:
list.pOptions[1].Value.pszValue = "1.1.1.1:9999";

我代码依然可以访问网页[/QUOTE]

我说了啊。 你打开138看看呗。 有没有代理成功。这种明显是没有代理成功。
2014-6-11 18:49
0
雪    币: 100
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
既然IP是1.1.1.1依然可以访问网页了 是我的代码有误
2014-6-11 20:46
0
雪    币: 100
活跃值: (10)
能力值: ( 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);
2014-6-11 20:48
0
游客
登录 | 注册 方可回帖
返回
//