#include
#include
int main(int argc, char* argv[])
{
CInternetSession session("HttpClient");
char * url = " http://www.imobile.com.cn/simcard.php?simcard=1392658";
CHttpFile* pfile = (CHttpFile *)session.OpenURL(url);
DWORD dwStatusCode;
pfile -> QueryInfoStatusCode(dwStatusCode);
if(dwStatusCode == HTTP_STATUS_OK)
{
CString content;
CString data;
while (pfile -> ReadString(data))
{
content += data + "rn";
}
content.TrimRight();
printf(" %sn " ,(LPCTSTR)content);
}
pfile -> Close();
delete pfile;
session.Close();
return 0 ;
}
#include
#include
int main(int argc, char* argv[])
{
CInternetSession session("HttpClient");
char * url = " http://www.imobile.com.cn/simcard.php?simcard=1392658";
CHttpFile* pfile = (CHttpFile *)session.OpenURL(url);
DWORD dwStatusCode;
pfile -> QueryInfoStatusCode(dwStatusCode);
if(dwStatusCode == HTTP_STATUS_OK)
{
CString content;
CString data;
while (pfile -> ReadString(data))
{
content += data + "rn";
}
content.TrimRight();
printf(" %sn " ,(LPCTSTR)content);
}
pfile -> Close();
delete pfile;
session.Close();
return 0 ;
}
其他如不从缓存中读取内容及如何使用代理连接现在就不说了,可以参考下面的链接,或者下次补上。另外不妨看看 Java 是如何读取 URL 内容的,更简单
GetMethod httpMethod = new GetMethod("http://unmi.blogcn.com");
int statusCode = new HttpClient().executeMethod(httpMethod);
if(statusCode == HttpStatus.SC_OK)
{
System.out.println(httpMethod.getResponseBodyAsString());
}
httpMethod.releaseConnection();
GetMethod httpMethod = new GetMethod("http://unmi.blogcn.com");
int statusCode = new HttpClient().executeMethod(httpMethod);
if(statusCode == HttpStatus.SC_OK)
{
System.out.println(httpMethod.getResponseBodyAsString());
}
httpMethod.releaseConnection();
内容取过来之后,总是希望从中拣出需要的数据,可惜 VC6 中没有自己的正则表达式库,所以下一步要学用 boost 的正则表达式库。
本文来自 280文秘网(https://www.it280.com),转载请保留网址和出处
【VC中使用CInternetSession抓取网页内容】相关文章:
2025年外省高中学业水平合格性考试成绩转入江苏认定的通告公布03-23
Vb中控件的自动排列03-23
中国大地保险公司实习报告03-23
2018国家电网新大纲财会类市场模拟卷多选题(二)03-23
07年4月北师大“中国古代文学史(一)”串讲(5)03-23
2023年广东梅州中考成绩查询时间及查分入口[7月7日起]03-23
2024年江苏中级导游等级考试准考证打印时间及入口(11月18日9:00起)03-23
2018湖南省农村信用社联合社招聘科技专业人才拟聘公告03-23
at(the)least和not(in)the least用法区别 相似词语辨析(17)03-23
5月11日开始报名!2023年内蒙古鄂尔多斯市乌审旗秋季幼升小入学条件和流程公布03-23
普通中学生入团志愿书500字通用范文03-23
