// downloadHTML.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
#include
#include
/*
This tutorial can be downloaded from supercomputingblog.com
This tutorial simply shows you how to easily and quickly download HTML files from the internet
from a C++ application.
This file was compiled with Visual Studio 2005.
For detailed instructions on how to compile this file, please visit supercomputingblog.com.
*/
using namespace std;
int main(int argc, char* argv[])
{
char webAddress[256];
char szFileName[80] = "result.html";
cout << "Please enter web address: "; // example: http://supercomputingblog.com
cin >> webAddress;
HRESULT hr = URLDownloadToFile(NULL, webAddress, szFileName,0, NULL);
if (hr == S_OK)
{
cout << "Success!\n";
// Open the file and print it to the console window
// Since the file was just written, it should still be in cache somewhere.
ifstream fin(szFileName);
char szBuff[2048];
while(fin.getline(szBuff, 2048))
{
cout << szBuff << "\n";
}
}
else
{
cout << "Operation failed with error code: " << hr << "\n";
}
return 0;
}