Ejemplo n.º 1
0
        void GetNewsText(string url)
        {
            NReadabilityWebTranscoder TwebTranscoder = new NReadability.NReadabilityWebTranscoder();
            bool   b;
            string detail;


            string page = TwebTranscoder.Transcode(url, DomSerializationParams.CreateDefault(), out b, out detail);


            if (b)
            {
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(page);



                var    body  = doc.DocumentNode.SelectSingleNode("//div[@id='readInner']").InnerText;
                string title = doc.DocumentNode.SelectSingleNode("//title").InnerText;


                richTextBox1.Text = title.Trim();
                richTextBox2.Text = detail.Trim();
                richTextBox3.Text = body.Trim();
            }
        }
Ejemplo n.º 2
0
        private string getcontent(string url)
        {
            var    t = new NReadability.NReadabilityWebTranscoder();
            bool   b;
            string detail = "";
            string page   = t.Transcode(url, DomSerializationParams.CreateDefault(), out b, out detail);

            if (b)
            {
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(page);


                // var imgUrl = doc.DocumentNode.SelectSingleNode("//meta[@property='og:image']").Attributes["content"].Value;
                var dd = doc.DocumentNode.SelectSingleNode("//div[@id='readInner']").InnerText;
                var tt = doc.DocumentNode.SelectSingleNode("//title").InnerText;
                richTextBox2.Text = detail;
                richTextBox1.Text = dd;
                return(dd);
            }
            return("");
        }