模拟访问网页,该如何处理
模拟访问网页
大概逻辑就是上述代码贴出来的样子, 使用InternetOpenA 和InternetOpenUrlA 好像不能真正的模拟访问网页, 虽然用抓包工具抓到包了, 但是用浏览器打开网页显示访问量没有增加
如果才能真正实现完全模拟后台访问网页
------最佳解决方案--------------------
调用都成功?
------其他解决方案--------------------
还要看后台是怎么统计访问量的
------其他解决方案--------------------
因为刚才用公司电脑上网,现在贴上完整代码
调用是成功的
hOpen = InternetOpenA(strAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if(!hOpen)//dwFlags并没证明是否正确,InternetOpenA也没证明是否正确,此处质检一一检查
{
MessageBox(0,"Internet连接错误!","MB_OK",0);
return 0;
}
DWORD dwSize;
CHAR szHead[] = "Accept: */*\r\n\r\n";
VOID* szTemp[16384];
HINTERNET hConnect;
if ( !(hConnect = InternetOpenUrlA ( hOpen, "http://192.168.1.141/1.mp3", szHead,
lstrlenA (szHead), INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0)))
大概逻辑就是上述代码贴出来的样子, 使用InternetOpenA 和InternetOpenUrlA 好像不能真正的模拟访问网页, 虽然用抓包工具抓到包了, 但是用浏览器打开网页显示访问量没有增加
如果才能真正实现完全模拟后台访问网页
------最佳解决方案--------------------
调用都成功?
------其他解决方案--------------------
还要看后台是怎么统计访问量的
------其他解决方案--------------------
因为刚才用公司电脑上网,现在贴上完整代码
调用是成功的
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <wininet.h>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 1024
#pragma comment(lib, "Wininet.lib")
void urlopen(vector<string>& v);
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR szFilePath[MAX_PATH + 1]={0};
GetModuleFileName(NULL, szFilePath, MAX_PATH);
TCHAR *p = _tcsstr(szFilePath, _T("TestHttpRequest.exe"));
*p = _T('\0');
_tcscat(szFilePath, "config.ini");
printf("path = %s", szFilePath);
ifstream ifstm(szFilePath);//打开配置文件
if(!ifstm){
printf("读取ini文件失败\n");
system("pause");
exit(1);
}
vector<string> v;//用来存储从文件中读取的内容
string tmp;
while(!ifstm.eof())
{
ifstm>>tmp;//一行一行的读取
printf("%s\n", tmp.c_str());
v.push_back(tmp); //将读取的信息存进vector里面 ,从尾部插入
}
ifstm.close();
urlopen(v);
system("pause");
return 0;
}
void urlopen(vector<string>& v)
{
HINTERNET hSession = InternetOpen(_T("UrlTest"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
do
{
if(hSession != NULL)
{
for(vector<string>::iterator it = v.begin(); it != v.end(); ++it)
{
try
{
HINTERNET hHttp = InternetOpenUrl(hSession, _T(it->c_str()), NULL, 0, INTERNET_FLAG_DONT_CACHE, 0);
if (hHttp != NULL)
{
printf("open %s success!\n", it->c_str());
}
else
{
printf("hHttp == NULL it->c_str() = %s \n", it->c_str());
}
}
catch(...)
{
printf("exception: InternetOpenUrl");