#include "stdafx.h"
#include
#include
#include
#include
#include
#include
#define MAXSIZE 1024
#pragma comment(lib, "Wininet.lib")
void urlopen(_TCHAR*);
std::string GetSubBtFind(char* lpsz);
int Token(const char* pSep, char* pStr, std::vector& refvec);
int _tmain(int argc, _TCHAR* argv[])
{
urlopen(_T("http://hq.sinajs.cn/list=AG1309"));
system("pause");
return 0;
}
void urlopen(_TCHAR* url)
{
HINTERNET hSession = InternetOpen(_T("UrlTest"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if(hSession != NULL)
{
HINTERNET hHttp = InternetOpenUrl(hSession, url, NULL, 0, INTERNET_FLAG_DONT_CACHE, 0);
if (hHttp != NULL)
{
wprintf_s(_T("%s\n"), url);
char Temp[MAXSIZE];
ULONG Number = 1;
while (Number > 0)
{
InternetReadFile(hHttp, Temp, MAXSIZE - 1, &Number);
Temp[Number] = '\0';
std::string str= GetSubBtFind(Temp);
;
char szpstr[1024];
strcpy(szpstr, str.c_str());
std::vector vec;
Token(",", szpstr, vec);
printf("%s\n", Temp);
for(int i=0; i
{
printf("%s\n", vec[i]);
}
}
InternetCloseHandle(hHttp);
hHttp = NULL;
}
InternetCloseHandle(hSession);
hSession = NULL;
}
}
std::string GetSubBtFind(char* lpsz)
{
std::string scrStr=lpsz;
std::string str_temp="";
int len=strlen(lpsz);
int beginPos=scrStr.find("\"");
scrStr=scrStr.substr(beginPos+1,len);
int endPos=scrStr.find("\"");
str_temp=scrStr.substr(0,endPos);
return str_temp;
}
int Token(const char* pSep, char* pStr, std::vector& refvec)
{
for(char* outer = strtok(pStr, pSep) ; NULL != outer; outer = strtok(NULL, pSep))
{
refvec.push_back(outer);
}
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有