/*
* HTMLParser.cpp
* Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
#include <sol\ole\HTMLParser.h>
////////////////////////////////////////
// Program main
void _tmain(int argc, TCHAR** argv) {
if (argc != 2) {
printf("Usage:HTMLParser.exe htmlFileFullPath\n");
return;
}
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr)) {
return;
}
const TCHAR* filePath = argv[1];
try {
SOL::HTMLParser* parser = new SOL::HTMLParser();
hr = parser->loadFromFile(filePath);
if (SUCCEEDED(hr)){
_tprintf(_T("OK. Loaded an HTMLFile %s\n"), filePath);
MSHTML::IHTMLDocument2Ptr doc = parser->getHTMLDocument();
MSHTML::IHTMLElementPtr body =doc->Getbody();
_bstr_t bodyHtml =body->GetouterHTML();
_tprintf(_T("BODY=[%s]\n"), (const TCHAR*)bodyHtml);
} else {
_tprintf(_T("ERROR=[%x]. Failed to load an HTMLFile %s\n"), hr, filePath);
}
parser->Release();
} catch (_com_error& ex) {
_tprintf(_T("Com error %s\n"), (const TCHAR*)ex.ErrorMessage());
} catch (HRESULT hr) {
_tprintf(_T("Exception: %x\n"), hr);
}
::CoUninitialize();
}
|