T
trint
How can I select view source of the current page in IE with c#?
I got the current page with this:
private void FrmMain_Load(object sender, System.EventArgs e)
{
object loc = "http://www.google.com/";
object null_obj_str = "";
System.Object null_obj = 0;
this.axWebBrowser1.Navigate2(ref loc , ref null_obj, ref null_obj,
ref null_obj_str, ref null_obj_str);
}
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
switch(Task)
{
case 1:
HTMLDocument myDoc = new HTMLDocumentClass();
myDoc = (HTMLDocument) axWebBrowser1.Document;
// a quick look at the google html source reveals:
// <INPUT maxLength="256" size="55" name="q">
//
HTMLInputElement otxtSearchBox = (HTMLInputElement) myDoc.all.item
("q", 0);
otxtSearchBox.value = "cargo ship companies";
// google html source for the I'm Feeling Lucky Button:
// <INPUT type=submit value="I'm Feeling Lucky" name=btnI>
//
HTMLInputElement btnSearch = (HTMLInputElement) myDoc.all.item
("btnI", 0);
btnSearch.click();
Task++;
break;
case 2:
// continuation of automated tasks...
break;
}
}
After I can "view source" code, I want to save it as a text file.
Thanks,
Trint
I got the current page with this:
private void FrmMain_Load(object sender, System.EventArgs e)
{
object loc = "http://www.google.com/";
object null_obj_str = "";
System.Object null_obj = 0;
this.axWebBrowser1.Navigate2(ref loc , ref null_obj, ref null_obj,
ref null_obj_str, ref null_obj_str);
}
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
switch(Task)
{
case 1:
HTMLDocument myDoc = new HTMLDocumentClass();
myDoc = (HTMLDocument) axWebBrowser1.Document;
// a quick look at the google html source reveals:
// <INPUT maxLength="256" size="55" name="q">
//
HTMLInputElement otxtSearchBox = (HTMLInputElement) myDoc.all.item
("q", 0);
otxtSearchBox.value = "cargo ship companies";
// google html source for the I'm Feeling Lucky Button:
// <INPUT type=submit value="I'm Feeling Lucky" name=btnI>
//
HTMLInputElement btnSearch = (HTMLInputElement) myDoc.all.item
("btnI", 0);
btnSearch.click();
Task++;
break;
case 2:
// continuation of automated tasks...
break;
}
}
After I can "view source" code, I want to save it as a text file.
Thanks,
Trint