 |
|
 |
Thanks you!
My Homepage : http://blog.csdn.net/accesine960
china,beijing
|
|
|
|
 |
|
 |
Thanks for the simple technique to get the html content of an IHTMLDocument2 !
|
|
|
|
 |
|
 |
private void button1_Click(object sender, EventArgs e)
{
WebRequest webRequest = WebRequest.Create(textBox1.Text.ToString());
webRequest.Timeout = 100000;
WebResponse webResponse = webRequest.GetResponse();
Stream s = webResponse.GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.ASCII);
String doc = sr.ReadToEnd();
int byteNum = doc.Length;
richTextBox1.Text = doc;
}
Sniper167
|
|
|
|
 |
|
 |
In addition of using mshtml, I used another way that only use socket no MFC, no Win32 API like this:
string request = "GET / HTTP/1.0";
request.append("Host: yoursite.com");
request.append("");
mySocket.send(request);
string respone = mySocket.response();
My English isn't good, so you mayn't understand what I said
|
|
|
|
 |
|
 |
hi,
is there a possibility to receive the http-header of
the loaded url?
what i want to do is to check if the loaded url
is available or not and i want to do only one
server connection.
thanks for your help.
best regards
emmi
|
|
|
|
 |
|
 |
hi,
pl. send us the complete explaination of your code ro get the html content.
rdgs ,
glen_codeproject
(glenvdsilva@gmail.com)
-- modified at 23:18 Wednesday 29th March, 2006
|
|
|
|
 |
|
 |
Send what, to whom, to where?
|
|
|
|
 |
|
 |
email is :
glenvdsilva@gmail.com
rgds,
glen_codeproject
-- modified at 23:27 Wednesday 29th March, 2006
|
|
|
|
 |
|
 |
Thanks! I was struggling with this for past couple of days trying to get the HTML source from IHTMLDocument2 interface. I took over a project written in Managed C++ .NET (not my specialty), and my only solution that I found was to extract the source from IHTMLDocument2. However I could not figure out how to properly enumerate through the IHTMLElementCollection returned by 'all' method.
Your get_Parent method saved my day!
|
|
|
|
 |
|
 |
This works in VC6:
CString buffer;
CInternetSession isess;
CHttpFile* f = (CHttpFile*) isess.OpenURL("http://test.com/test.htm");
while(f->ReadString(buffer))
{
htmlstring += buffer;
}
The full source code for the page is now in a CString.
Hugh Jampton
|
|
|
|
 |
|
 |
Your method is much neater that mine. I appreciate your taking the time to show me.
I implemented yours, but discovered a memory leak. It is probably so obvious that you assumed I would do it, but the file needs to be closed, and the file pointer f needs to be destroyed.
bool MyApp::GetDocumentHTML(CString &str)
{
CString buffer;
CInternetSession isess;
CHttpFile* f = (CHttpFile*)isess.OpenURL(m_Browser.GetLocationURL());
while(f->ReadString(buffer))
{
str += buffer;
}
f->Close();
delete f;
return true;
}
|
|
|
|
 |
|
 |
It is not quite the same.
CHtmlView will handle HTTP (302) redirect, Javascript/VBScript redirect, onload, etc.
Unless you are sure the page you want is exactly that URL (which usually not the case unless your site is static), using CHtmlView will be more close to WYSIWYG.
|
|
|
|
 |
|
 |
Insteal of using the HTMLView or other tricks, why not simply download the whole HTML File ?
Add this line in your code :
URLDownloadToFile(0, "http://www.ANYTHING.com/index.html", "c:\\test.html", 0, 0);
and you will have the HTML file on your HD.
Jo
JoCool
|
|
|
|
 |
|
 |
That's fine for getting the HTML onto disk, but I wanted access to it in my program.
My article erroneously states that I "needed to store the full HTML of a web page". In fact, my app modifies it and displays the modified copy.
Writing to disk and then reading from it opens the door for a lot of needless problems.
|
|
|
|
 |
|
 |
This is the way I do it in a project of mine (for www.zeta-producer.com [^] to be exact ).
I don't know exactly, but I recall that I copied something from the CHtmlEditCtrl [^] class of MFC.
const CString CMyHtmlView::GetDocumentHtml() const
{
MsHtml::IHTMLDocument2Ptr doc = GetHtmlDocument();
IPersistStreamInitPtr stream = doc;
CStreamOnCString sstream;
stream->Save( static_cast<IStream*>(&sstream), false );
CString result;
VERIFY(sstream.CopyData( result ));
return result;
}Maybe this helps you.
--
Affordable Windows-based CMS: www.zeta-producer.com
|
|
|
|
 |
|
 |
Looks good, and I appreciate the feedback.
I'm still using Visual Studio 6.0 which does not support CStreamOnCString class.
|
|
|
|
 |
|
 |
On VC 6, I simply copied the CStreamOnCString class from the MFC 7 library into my project to use it
--
Affordable Windows-based CMS: www.zeta-producer.com
|
|
|
|
 |