C++实现发送HTTP请求
2016-08-22 01:49
411 查看
#include <stdio.h>
#include <windows.h>
#include <wininet.h>
#define MAXSIZE 1024
#pragma comment(lib, "Wininet.lib")
void urlopen(_TCHAR*);
int _tmain(int argc, _TCHAR* argv[])
{
urlopen(_T("http://coderzh.cnblogs.com"));
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);
BYTE Temp[MAXSIZE];
ULONG Number = 1;
while (Number > 0)
{
InternetReadFile(hHttp, Temp, MAXSIZE - 1, &Number);
Temp[Number] = '\0';
printf("%s", Temp);
}
InternetCloseHandle(hHttp);
hHttp = NULL;
}
InternetCloseHandle(hSession);
hSession = NULL;
}
}
http://www.cnblogs.com/coderzh/archive/2008/11/24/1340134.html
#include <windows.h>
#include <wininet.h>
#define MAXSIZE 1024
#pragma comment(lib, "Wininet.lib")
void urlopen(_TCHAR*);
int _tmain(int argc, _TCHAR* argv[])
{
urlopen(_T("http://coderzh.cnblogs.com"));
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);
BYTE Temp[MAXSIZE];
ULONG Number = 1;
while (Number > 0)
{
InternetReadFile(hHttp, Temp, MAXSIZE - 1, &Number);
Temp[Number] = '\0';
printf("%s", Temp);
}
InternetCloseHandle(hHttp);
hHttp = NULL;
}
InternetCloseHandle(hSession);
hSession = NULL;
}
}
http://www.cnblogs.com/coderzh/archive/2008/11/24/1340134.html
相关文章推荐
- C++发送HTTP请求的实现代码
- C++实现发送HTTP请求 - CoderZh - 博客园
- C++实现发送HTTP请求
- C++实现发送HTTP请求
- C++实现发送HTTP请求
- 用socket发送流数据示--用 php://input? 接受post数据(可实现php和c/c++数据通讯)
- c++ 发送http请求
- C++ 发送HTTP请求
- 通过WinInet API来实现表单提交并设置获取COOKIE(C++ http请求
- 利用js实现页面关闭时发送http请求
- C++发送HTTP请求获取网页HTML代码
- C++发送HTTP请求---亲测可行(转)
- 一组实现邮件发送功能的C++封装类 — SMailer
- C++实现RTMP协议发送H.264编码及AAC编码的音视频
- JAVA实现发送HTTP请求,把请求来的页面下载到本地
- 用C++实现HTTP服务器 - 如何控制一个套接字的发送带宽
- [C++] Linux C++ 实现 http请求 (未验证)
- GSM短信发送PDU编码解码C++控制台实现
- 用Ruby实现 Web Service Server ,并用Ruby发送 HTTP请求 Web Service
- 用C++实现读取windows日志并用zlib压缩后通过jwsmtp邮件发送出去.