I'm trying to get a string that represents the DOM of web pages using System.NET - The only way I know. I used WebClient.DownloadStringAsync, but it acts very strange; sometimes gives result, but very short string! Does not the expected result from DownloadStringCompleted event handler is the entire string of the web page, like using BugZilla? or View Source from any browser?, and sometimes it does not respond!
Here is the code, anyway nothing new:
Expand|Select|Wrap|Line Numbers
- WebClient c = new WebClient();
- c.DownloadStringCompleted += new DownloadStringCompletedEventHandler(c_DownloadStringCompleted);
- c.DownloadStringAsync(new Uri("http://www.msn.com"));
- ....
- ...
- void c_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
- {
- MessageBox.Show(e.Result);
- //txtUrl.Text = e.Result;
- }
Thanks a lot, and I appreciate your help.