-
April 20th, 2010, 09:53 AM
#1
WebBrowser - download page without displaying it
hi, my app have to visit many pages and i want to optimize it a little bit,
i have already disabled images/videos/sounds downloading(i care only about html content), is there a way to download page with webbrowser but do not display it ? i am well aware of httpwebrequest etc. but html content downloaded this way is different from browser source code of website, probably something with ajax etc
EDIT:
solution where i dont need webbrowser, and downloaded html content will be exactly the same as browser source will be much more appreciated
Last edited by sv13; April 20th, 2010 at 10:49 AM.
-
April 20th, 2010, 01:02 PM
#2
Re: WebBrowser - download page without displaying it
You can do this from the code-behind to get the HTML of a webpage...
Code:
private void button1_Click(object sender, EventArgs e)
{
WebBrowser browser = new WebBrowser();
browser.Navigate("http://www.google.com");
browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted);
}
void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser b = (WebBrowser)sender;
string response = b.DocumentText;
// response will now contain the HTML from the page.
}
===============================
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|