Last active
December 15, 2015 21:39
-
-
Save yesez/5327052 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<string> GetImageInHtmlNotice(string url) | |
{ | |
var page = await GetNodeHtml(url); | |
string selector = string.Empty; | |
selector = ".image img"; | |
var consulta = (from item in page.QuerySelectorAll(selector) | |
select item).FirstOrDefault(); | |
string result = string.Empty; | |
if (consulta != null) | |
{ | |
result = consulta.Attributes["src"].Value; | |
} | |
return result; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<HtmlAgilityPack.HtmlNode> GetNodeHtml(string url) | |
{ | |
var doc = new HtmlAgilityPack.HtmlDocument(); | |
var client = new System.Net.Http.HttpClient(); | |
var stream = await client.GetStreamAsync(url); | |
doc.Load(stream); | |
var page = doc.DocumentNode; | |
return page; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment