Get wepage source code
-
Hi ! I use the object create my own web browser. private AxSHDocVw.AxWebBrowser instVisualObjectCreator; then by using instVisualObjectCreator.Navigate(); I show it inside my client form. But can i use this facility (instVisualObjectCreator object) to get the source of the web page. Is there a method to get the source code from this object. I've gone through the documentation but somehow the solution has illuded me. Thanx in Advance
-
Hi ! I use the object create my own web browser. private AxSHDocVw.AxWebBrowser instVisualObjectCreator; then by using instVisualObjectCreator.Navigate(); I show it inside my client form. But can i use this facility (instVisualObjectCreator object) to get the source of the web page. Is there a method to get the source code from this object. I've gone through the documentation but somehow the solution has illuded me. Thanx in Advance
using System.Runtime.InteropServices; IHTMLDocument2 doc = (IHTMLDocument2) instVisualObjectCreator.Document; UCOMIPersistFile pf = (UCOMIPersistFile) doc; pf.Save(@"c:\myhtmlpage.html",true); PS : the IHTMLDocument2 interface is from the mshtml primary interop library (which you can add to your project, c:\program files\microsoft.NET\primary interop assemblies\microsoft.mshtml.dll).
-
using System.Runtime.InteropServices; IHTMLDocument2 doc = (IHTMLDocument2) instVisualObjectCreator.Document; UCOMIPersistFile pf = (UCOMIPersistFile) doc; pf.Save(@"c:\myhtmlpage.html",true); PS : the IHTMLDocument2 interface is from the mshtml primary interop library (which you can add to your project, c:\program files\microsoft.NET\primary interop assemblies\microsoft.mshtml.dll).
Or he could do it the "Completely managed" way:
using System; using System.Net; using System.Text; namespace Utilities { class WebPage { static string GetHtml(string address) { WebClient client = new WebClient(); return Encoding.Default.GetString(client.DownloadData(address)); } } }
Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing
-
Or he could do it the "Completely managed" way:
using System; using System.Net; using System.Text; namespace Utilities { class WebPage { static string GetHtml(string address) { WebClient client = new WebClient(); return Encoding.Default.GetString(client.DownloadData(address)); } } }
Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing
Geeee! This is ok for a completely IE-less scenario.
-
Geeee! This is ok for a completely IE-less scenario.
Yeah. That was my point. Why on earth would you need to use IE?:confused:
Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing
-
Yeah. That was my point. Why on earth would you need to use IE?:confused:
Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing
Well, I guess that saving the html source code from the current web page is the final scenario step for Windows apps that embed IE because they want to show the web page(s). The .NET WebClient helper class is no substitution for showing pages.
-
Well, I guess that saving the html source code from the current web page is the final scenario step for Windows apps that embed IE because they want to show the web page(s). The .NET WebClient helper class is no substitution for showing pages.
Ah...I see now. I didn't think of it in terms of actually showing pages...just downloading them and parsing their source (which I've done a lot of recently).
Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing