Solved

How to read the HTML source with CViewHtml or URL with MFC?

Posted on 2006-11-04
7
676 Views
Last Modified: 2013-11-20
Hi Experts,

I have developed a class that driver the CViewHtml to browser HTML from a URL,
Now, I want to get all the contents of html page to save to the local html file, how can I do this?
How we reat the html contents from a URL? or read the contents from CViewHtml control?

Thank in advance!
0
Comment
Question by:Mobinex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
7 Comments
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 500 total points
ID: 17876373
You can use GetHtmlDocument() and then manipulate the document directly save it, change it, etc.

You may use code similar to following :

e.g.

// Note:  CMyHtmlView is derived from CHtmlView

CString CMyHtmlView::GetHtmlText()
{
 CString Text;
 HRESULT hr;
 IHTMLDocument2 *pDoc = NULL;

 // Load the current document into pDoc
 hr = this->GetHtmlDocument()->QueryInterface(IID_IHTMLDocument2, (void **) &pDoc);

 if (hr == S_OK)
 {
  BSTR pelementText = NULL;
  IHTMLElement *Element = NULL;

  // Get the body
  pDoc->get_body(&Element);

  Element->get_innerHTML(&pelementText);
  Text = pelementText;

 } // End HTMLdocument is valid (HR == OK)

 return Text;
}

Hope this helps
-MAHESH
0
 
LVL 1

Author Comment

by:Mobinex
ID: 17878589
Many thank for this,
I have question next. How to get images infomation to download to client? Can we cache all images and text with CViewHtml to app folder(my ower folder)?

Thank in advance!
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17879015
For images you may use IHTMLDocument2::get_images() and IHTMLImgElement

Have a Look here : http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20294289.html

-MAHESH
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17879082
Alternatively you may use UrlDownloadToFile() API function to download elements, images, entire webpage to disk.
http://msdn.microsoft.com/workshop/networking/moniker/reference/functions/urldownloadtofile.asp

-MAHESH
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 98
ASCII Non-Printable characters/codes and their HTML equivalents 6 143
Work with App store 7 92
Problem to Office 1 42
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question