#include <stdio.h>
#include <windows.h>
#include <wininet.h>
#pragma comment(lib, "wininet.lib")
BOOL HttpDump(const char *lpszServerName, int iPort, const char *lpszObjectName)
{
char cBuf[2048];
DWORD dwRead;
HINTERNET hINet = NULL, hConnection = NULL, hRequest = NULL;
__try
{
hINet = InternetOpen("HttpDump/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if(NULL == hINet)
{
printf("InternetOpen Failed. Error Code: %d\n", GetLastError());
return FALSE;
}
hConnection = InternetConnect(hINet, lpszServerName, iPort, " "," ", INTERNET_SERVICE_HTTP, 0, 0);
if(NULL == hConnection )
{
printf("InternetConnect Failed. Error Code: %d\n", GetLastError());
return FALSE;
}
hRequest = HttpOpenRequest(hConnection, "GET", lpszObjectName, NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTIO
用WinINet API获取网页源代码
最新推荐文章于 2020-01-02 00:17:48 发布
本文详细介绍了如何利用WinINet API在Windows环境下进行互联网访问,从而获取网页的源代码。通过实例代码,展示了包括初始化Internet会话、打开URL、发送HTTP请求和接收响应等关键步骤,为开发者提供了直接操作网络请求的实现方式。
摘要由CSDN通过智能技术生成