is there html parser using x-path uwp - windows 10?
what's easy/best way of exploring html in windows 10 ?
solution 1: install-package htmlagilitypack
https://www.nuget.org/packages/htmlagilitypack/
solution 2: parsing html
private async void parsing(string website) { try { httpclient http = new httpclient(); var response = await http.getbytearrayasync(website); string source = encoding.getencoding("utf-8").getstring(response, 0, response.length - 1); source = webutility.htmldecode(source); htmldocument resultat = new htmldocument(); resultat.loadhtml(source); list<htmlnode> toftitle = resultat.documentnode.descendants().where (x => (x.name == "div" && x.attributes["class"] != null && x.attributes["class"].value.contains("block_content"))).tolist(); var li = toftitle[6].descendants("li").tolist(); foreach (var item in li) { var link = item.descendants("a").tolist()[0].getattributevalue("href", null); var img = item.descendants("img").tolist()[0].getattributevalue("src", null); var title = item.descendants("h5").tolist()[0].innertext; listproduct.add(new product() { img = img, title = title, link = link }); } } catch (exception) { messagebox.show("network problem!"); } } windows 8 parsing html using c# sample in c# visual studio 2013[^]
Comments
Post a Comment