示例#1
0
        public static string Start(AdDataItem info)
        {
            string html  = "0";
            string shtml = DN.Framework.Utility.WebClientHelper.GetSend(info.ClientUrl, info.Encoding, info.Encoding);

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(shtml);
            string xpath = "//tr/td[2]";

            if (!string.IsNullOrEmpty(info.XPath))
            {
                xpath = info.XPath;
            }

            int count = 0;
            var list  = info.ClientUrl.Split(',');

            foreach (var item in list)
            {
                if (!string.IsNullOrEmpty(item))
                {
                    count = count + GetUrl(item, xpath);
                }
            }
            html = count.ToString();

            return(html);
        }
示例#2
0
        public static string GetDb(AdDataItem info, string cookie)
        {
            string     scookie = cookie.Split(';')[0];
            HttpHelper http    = new HttpHelper();
            HttpItem   item    = new HttpItem()
            {
                URL               = "http://guanggao-pv.uicp.cn/dfcx/commonQuery/dtquery.do?sqlname=SQL_Zq_Advvist_Today_Stat.advlist", //URL     必需项
                Method            = "GET",                                                                                              //URL     可选项 默认为Get
                Timeout           = 100000,                                                                                             //连接超时时间     可选项默认为100000
                ReadWriteTimeout  = 30000,                                                                                              //写入Post数据超时时间     可选项默认为30000
                IsToLower         = false,                                                                                              //得到的HTML代码是否转成小写     可选项默认转小写
                Cookie            = scookie,                                                                                            //"JSESSIONID,=38837539686B1D31F3D8BD0AFA67A972",//字符串Cookie     可选项
                UserAgent         = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",                         //用户的浏览器类型,版本,操作系统     可选项有默认值
                Accept            = "text/html, application/xhtml+xml, */*",                                                            //    可选项有默认值
                ContentType       = "text/json",                                                                                        //返回类型    可选项有默认值
                Referer           = "http://guanggao-pv.uicp.cn",                                                                       //来源URL     可选项
                Allowautoredirect = false,                                                                                              //是否根据301跳转     可选项
                //AutoRedirectCookie = False,//是否自动处理Cookie     可选项
                //CerPath = "d:\123.cer",//证书绝对路径     可选项不需要证书时可以不写这个参数
                //Connectionlimit = 1024,//最大连接数     可选项 默认为1024
                Postdata = "loginname=duonian&pwd=duonian", //Post数据     可选项GET时不需要写
                                                            //ProxyIp = "192.168.1.105:2020",//代理服务器ID     可选项 不需要代理 时可以不设置这三个参数
                                                            //ProxyPwd = "123456",//代理服务器密码     可选项
                                                            //ProxyUserName = "******",//代理服务器账户名     可选项
                ResultType = ResultType.String,             //返回数据类型,是Byte还是String
            };
            HttpResult result = http.GetHtml(item);
            string     html   = result.Html;

            return(html);
        }
示例#3
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static string GetCount(AdDataItem info)
        {
            string html   = "0";
            int    result = 0;

            try
            {
                string shtml = DN.Framework.Utility.WebClientHelper.GetSend(info.ClientUrl, info.Encoding, info.Encoding);
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(shtml);
                string xpath = "//script[@id='tpl_home']";
                if (!string.IsNullOrEmpty(info.XPath))
                {
                    xpath = info.XPath;
                }
                var node = doc.DocumentNode.SelectNodes(xpath);
                if (node != null)
                {
                    foreach (var item in node)
                    {
                        int count = 0;
                        var list  = item.InnerText.Split('/')[0];
                        int.TryParse(list, out count);
                        result += count;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(html);
        }
示例#4
0
        static int GetUrl(AdDataItem info, string url)
        {
            int result = 0;

            string shtml = DN.Framework.Utility.WebClientHelper.GetSend(url, info.Encoding, info.Encoding);

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(shtml);
            string xpath = "//tbody/tr/td[4]";

            if (!string.IsNullOrEmpty(info.XPath))
            {
                xpath = info.XPath;
            }
            var node = doc.DocumentNode.SelectNodes(xpath);

            if (node != null)
            {
                foreach (var item in node)
                {
                    int count = 0;
                    var list  = item.InnerText.Split('/')[0];
                    int.TryParse(list, out count);
                    result += count;
                }
            }

            return(result);
        }
示例#5
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static string Start(AdDataItem info)
        {
            string html = "0";

            try
            {
                string shtml = DN.Framework.Utility.WebClientHelper.GetSend(info.ClientUrl, info.Encoding, info.Encoding);
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(shtml);
                string xpath = "//script[@id='tpl_home']";
                if (!string.IsNullOrEmpty(info.XPath))
                {
                    xpath = info.XPath;
                }
                var node = doc.DocumentNode.SelectSingleNode(xpath);
                if (node != null)
                {
                    var list = node.InnerText.Replace("<em>", "@").Split('@');

                    if (list.Length >= 2)
                    {
                        html = list[2].Substring(0, list[2].IndexOf("</em>"));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(html);
        }
示例#6
0
        public static string GetCount(AdDataItem info)
        {
            //string url = "http://guanggao-pv.uicp.cn/dfcx/logout.do";
            //string rurl = "http://guanggao-pv.uicp.cn/dfcx/loginsys.do";
            string purl     = "http://guanggao-pv.uicp.cn/dfcx/loginsys.do?loginname=duonian&pwd=duonian";
            string cookieid = info.Purl;
            string html     = PostLogin(purl, cookieid);
            string count    = "0";
            string shtml    = "";
            int    tcoun    = 0;
            int    tmcount  = 0;

            if (html.Length > 10)
            {
                shtml = GetDate("http://guanggao-pv.uicp.cn/dfcx/commonQuery/dtquery.do?sqlname=SQL_Zq_Advvist_Today_Stat.advlist", cookieid);

                var list = shtml.Replace("\"", "").Split(',');

                for (int i = 0; i < list.Length; i++)
                {
                    var item = list[i].Split(':');
                    if (item.Length == 2)
                    {
                        if (item[0] == "ips")
                        {
                            count = item[1];
                            int.TryParse(count, out tcoun);
                            tmcount = tmcount + tcoun;
                        }
                    }
                }

                shtml = GetDate("http://guanggao-pv.uicp.cn/dfcx/commonQuery/dtquery.do?sqlname=SQL_Zq_Advvist_Today_Stat.advhistorylist", cookieid);
                var list1 = shtml.Replace("\"", "").Split(',');

                for (int i = 0; i < list1.Length; i++)
                {
                    var item = list1[i].Split(':');
                    if (item.Length == 2)
                    {
                        if (item[0] == "ips")
                        {
                            count = item[1];
                            int.TryParse(count, out tcoun);
                            tmcount = tmcount + tcoun;
                        }
                    }
                }

                Console.WriteLine(tmcount.ToString());
            }

            return(tmcount.ToString());
        }
示例#7
0
        public static string Start(AdDataItem info)
        {
            string html = post(info.ClientUrl);

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(html);
            var list = doc.DocumentNode.SelectNodes("//tr/td");

            foreach (var item in list)
            {
            }

            return(html);
        }
示例#8
0
        public static int Start(AdDataItem data)
        {
            int count = 0;

            var list = data.ClientUrl.Split(',');

            foreach (var item in list)
            {
                if (!string.IsNullOrEmpty(item))
                {
                    count = count + GetUrl(data, item);
                }
            }

            return(count);
        }
示例#9
0
        static void Main(string[] args)
        {
            //{
            //            "AdId": 131,
            //"UserId": 55,
            //"ClientUrl": "http://ggz.reux.com.cn/advince/ipdetail/14247110",
            //"Encoding": "UTF-8",
            //"XPath": "/html/body/div[1]/div/div/div/div[6]/div[2]/em",
            //"App": 0
            //}

            AdDataItem info = new AdDataItem();

            info.ClientUrl = "http://admin.weiyouzj.com:8088/marticletask/customelistRelate?customeName=xiaochuang";
            info.XPath     = "//tbody/tr/td[4]";
            info.Encoding  = "UTF-8";
            //WebSite.dadaBLL.GetCount(info);
            string open = douzhuanDfBLL.GetCount();

            //string resutl = GetCount(info);
            Console.WriteLine("数据更新完成。");
            Console.ReadKey();
        }
        public static string Start(AdDataItem date)
        {
            string url = "http://admin.beijingfengchuankeji.com/member.php/Public/checkLogin.html";
            //string url = "http://ads.k4884.com/index.php/Public/checkLogin";
            string rurl = "http://admin.beijingfengchuankeji.com/member.php/Index/index.html";
            string purl = "username=momo123&password=123456";

            if (!string.IsNullOrEmpty(date.Purl))
            {
                purl = date.Purl;
            }
            string html  = PostLogin(url, rurl, purl);
            string count = "0";
            string shtml = "";

            if (html.IndexOf("/member.php/Index/index.html") != -1)
            {
                shtml = post(rurl);

                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(shtml);

                string sxpath = "//*[@id=\"marqueebox0\"]/li/div[5]";
                if (!string.IsNullOrEmpty(date.XPath))
                {
                    sxpath = date.XPath;
                }


                var node = doc.DocumentNode.SelectSingleNode(sxpath);
                count = node.InnerText;
                count = count.Replace("&nbsp;", "").Replace("\t", "").Replace("\n", "").Replace("\r", "").Replace(" ", "");
                Console.WriteLine(count);
            }

            return(count);
        }
示例#11
0
 public static string Start(AdDataItem data)
 {
     return(PostLogin(""));
 }