Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Basead in this page: <a href="http://www.img.com.br/default.aspx" rel="nofollow">page</a></p> <pre><code>public sealed class UtilParserHTML { //Private Fields private Uri Uri; private Stream StreamPage; private HttpWebRequest HttpRequest; private HttpWebResponse HttpResponse; //Public Fields public HtmlDocument HtmlDocument { private set; get; } public UtilParserHTML() { if (this.HtmlDocument == null) HtmlDocument = new HtmlDocument(); } public void LoadHTMLPage(string UrlPage) { if (string.IsNullOrEmpty(UrlPage)) throw new ArgumentNullException(""); CookieContainer cookieContainer = new CookieContainer(); this.Uri = new Uri(UrlPage); this.HttpRequest = (HttpWebRequest)WebRequest.Create(UrlPage); this.HttpRequest.Method = WebRequestMethods.Http.Get; this.HttpRequest.CookieContainer = cookieContainer; this.HttpResponse = (HttpWebResponse)this.HttpRequest.GetResponse(); this.StreamPage = this.HttpResponse.GetResponseStream(); this.HtmlDocument.Load(StreamPage); } public void LoadHTMLPage(FileStream StreamPage) { if (StreamPage == null) throw new ArgumentNullException(""); HtmlDocument.Load(StreamPage); } public HtmlNodeCollection GetNodesByExpression(string XPathExpression) { if (string.IsNullOrEmpty(XPathExpression)) throw new ArgumentNullException(""); return this.HtmlDocument.DocumentNode.SelectNodes(XPathExpression); } </code></pre> <p>Use <a href="http://www.w3schools.com/xpath/default.asp" rel="nofollow">XPath</a> to navigate in html. In this case I used this Xpath expression : //div[@class='arrowRibbon'] //img</p> <p>Look: <strong>...</strong></p> <pre><code>this.ParserHTML.LoadHTMLPage("http://www.img.com.br/default.aspx"); HtmlNodeCollection HtmlNodeCollectionResult = this.ParserHTML.GetNodesByExpression(Page.XPathExpression); if (HtmlNodeCollectionResult != null) { foreach (HtmlNode NodeResult in HtmlNodeCollectionResult) { var src = NodeResult.Attributes["src"].Value; } } </code></pre> <p><strong>...</strong></p> <p><strong>EDIT</strong></p> <p>Look this complete example with width and height:</p> <pre><code>this.ParserHTML.LoadHTMLPage("http://www.w3schools.com/tags/tag_img.asp"); HtmlNodeCollection HtmlNodeCollectionResult = this.ParserHTML.GetNodesByExpression("//div[@class='tryit_ex'] //img"); if (HtmlNodeCollectionResult != null) { foreach (HtmlNode NodeResult in HtmlNodeCollectionResult) { var src = NodeResult.Attributes["src"].Value; var w = NodeResult.Attributes["width"].Value; var h = NodeResult.Attributes["height"].Value; } } </code></pre> <p>Hope this help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload