网页解析-WP8-HTMLAgilityPack [英] Web Page Parsing - WP8 - HTMLAgilityPack

查看:100
本文介绍了网页解析-WP8-HTMLAgilityPack的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上是在尝试解析此网页的内容, http://www .cryptocoincharts.info/v2/coins/show/tips

I am actually trying to parse the content of this webpage, http://www.cryptocoincharts.info/v2/coins/show/tips

特别是我需要获取数字,例如当前难度",到目前为止开采的硬币"等

In particular I'd need to get the numbers, like "Current Difficulty", "Mined coins till now" etc

我实际上不确定该怎么做,我实际上位于我的电话号码所在的部分,但是我无法编写代码来实际获得这些电话号码:(

I am not actually sure how to do that, I actually located the section where my numbers are, yet I am not able to write the code to actually get those numbers out :(

在此先感谢您的帮助!

这是我到目前为止的代码:

This is the code I have so far:

protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string htmlPage = "";
            using (var client = new HttpClient())
            {
                try
                {
                    htmlPage = await client.GetStringAsync("http://www.cryptocoincharts.info/v2/coins/show/tips");
                }
                catch (HttpRequestException exc) { }
            }

        HtmlDocument htmlDocument = new HtmlDocument();
        htmlDocument.LoadHtml(htmlPage);

推荐答案

HttpClient client = new HttpClient();
var doc = new HtmlAgilityPack.HtmlDocument();
var html = await client.GetStringAsync("http://www.cryptocoincharts.info/v2/coins/show/tips");
doc.LoadHtml(html);

var result = doc.DocumentNode.SelectSingleNode("//table[@class='table table-striped']")
                .Descendants("tr")
                .Skip(1)
                .Select(tr => new
                {
                    Desc = tr.SelectSingleNode("td[1]").InnerText,
                    Val = WebUtility.HtmlDecode(tr.SelectSingleNode("td[2]").InnerText)
                })
                .ToList();

这篇关于网页解析-WP8-HTMLAgilityPack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆