1

I've been using WebBrowser.Document to get certain element such id, tag, or div...but seem WebBrowser seems too slow to processing many URL address...Any idea?

Conrad Frix
  • 51,984
  • 12
  • 96
  • 155
Kiri十
  • 9
  • 1
  • 3

2 Answers2

0

You could try to include some opensource browsers and include them in the code

http://duckwebbrowser.codeplex.com/

http://xplora.codeplex.com/

Micah Armantrout
  • 6,781
  • 4
  • 40
  • 66
0

I've been using WebBrowser.Document to get certain element such id, tag, or div.

From your question's title and content its not clear from this statement that you need to use a Control which gets, parses and renders HTML.

Is sounds like you just to get and parse your HTML. If this is true you should probably use Html Agility Pack. HAP can get the HTML from a URL and it then parse it. You can then use linq or XPath or the traversal methods to get your tags and divs.

There are plenty of articles on how to use hap like this one How to use HTML Agility pack which includes examples and links.

One of the links includes this example by Farooq Kaiser which gets all the links in a document and add it to `List'

HtmlDocument doc = new HtmlDocument();
doc.Load(url);
HtmlNode root = doc.DocumentNode;

List<string> anchorTags = new List<string>();

foreach (HtmlNode link in root.SelectNodes("//a"))
{
    string att = link.OuterHtml;
    anchorTags.Add(att);
}
Community
  • 1
  • 1
Conrad Frix
  • 51,984
  • 12
  • 96
  • 155
  • here when i using webbrowser.. public void getLocation(string uri, string id) { WebBrowser wb = new WebBrowser(); wb.Url = new Uri(uri) string s; HtmlElement tableElem = wb.Document.GetElementById(id); s = tableElem.tableElem.GetAttribute("src"); messagebox.show(s); } i've to wait bit sec to get my webbrowser load the url, but then showing message bout ActiveX Control etc.etc. bout HAP, i still get problems to get the value HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.load(uri); s= doc.getelementbyid(id).getatributevalue("src","null"); but still not works – Kiri十 May 12 '12 at 01:53