コード例 #1
0
        public ActionResult detail(string url)
        {
            WebClient webClient = new WebClient();

            webClient.Headers.Add("user-agent", "Only a test!");
            string strUrl       = url;
            string pageContent  = webClient.DownloadString(strUrl);
            CQ     dom          = pageContent;
            CQ     article_body = dom.Find("div.pg-right-rail-tall").Eq(0).Find("article").Eq(0).Find("div.l-container").Eq(0);

            ViewBag.title = article_body.Children("h1").Text().ToString();
            article_body  = article_body.Children("div.pg-rail-tall__wrapper").Eq(0).Children("div.pg-side-of-rail").Eq(0);
            CQ temp = article_body.Find("div.media__video--thumbnail-wrapper").Eq(0);

            temp.Remove();
            temp = article_body.Find(".el__leafmedia.el__leafmedia--storyhighlights").Eq(0);
            temp.Remove();
            temp = article_body.Find(".el__embedded.el__embedded--standard");
            temp.Remove();
            temp = article_body.Find(".el__gallery--expandable.js__gallery--expandable.js__leafmedia--gallery");
            temp.Remove();
            temp = article_body.Find(".cn.cn-list-hierarchical-small-horizontal.cn--idx-0.cn-");
            temp.Remove();
            temp = article_body.Find("input.sharebar-video-embed-field");
            temp.Remove();
            temp = article_body.Find(".zn__containers");
            temp.Remove();
            temp = article_body.Find("img.media__image.media__image--responsive");
            for (int i = 0; i < temp.Length; i++)
            {
                CQ     t   = temp.Eq(i);
                string str = t.Attr("data-src-large");
                t.AttrSet(new { src = str });
            }
            temp = article_body.Find(".cn__column.carousel__content__item");
            temp.Remove();
            ViewBag.text = article_body.RenderSelection().ToString();

            return(View());
        }