Exemplo n.º 1
0
        public void timeCount(PdetailInfo pdetailInfo)
        {
            CheckForIllegalCrossThreadCalls = false;
            UserLogEvent?.Invoke();
            TimeSpan     ds        = pdetailInfo.StartTime - DateTime.Now - (pdetailInfo.Webtime - pdetailInfo.Systime);
            bool         isRelogin = false;
            ListViewItem item      = pid_listView.FindItemWithText(pdetailInfo.ID);

            while (ds.TotalSeconds >= 0)
            {
                ds = pdetailInfo.StartTime - DateTime.Now - (pdetailInfo.Webtime - pdetailInfo.Systime);
                double dH = ds.Hours;
                double dM = ds.Minutes;
                double dS = ds.Seconds;
                item.SubItems[1].Text = dH.ToString() + "时" + dM.ToString() + "分" + dS.ToString() + "秒";

                if (ds.TotalSeconds < 60 && isRelogin == false)
                {
                    UserLogEvent?.Invoke();
                    isRelogin = true;
                }
                Thread.CurrentThread.Join(1000);
            }
            TimeUpEvent?.Invoke(pdetailInfo.ID);// 发布信号
            // CheckForIllegalCrossThreadCalls = true;
        }
Exemplo n.º 2
0
        // 单个标的信息页面读取
        public PdetailInfo Pdetail(string URL)
        {
            string       Referer     = @"https://www.16pu.com/touzi.jhtml";
            Response     resp        = r.Get(URL, "", ref cookies, Referer);
            StreamReader trStream    = resp.getStream();
            PdetailInfo  pdetailInfo = Read_Pdetail(trStream);

            return(pdetailInfo);
        }
Exemplo n.º 3
0
        // 读取可投标的页面(读取离线网页,测试用)
        public List <PdetailInfo> Touzi2()
        {
            List <PdetailInfo> list         = new List <PdetailInfo>();
            string             URL          = @"..\..\..\..\测试网页\未登陆状态下.标的网页.html";
            StreamReader       streamReader = Comm.xmlRead(URL);
            PdetailInfo        pdetailInfo  = Read_Pdetail(streamReader);

            list.Add(pdetailInfo);
            return(list);
        }
Exemplo n.º 4
0
        // <私有> 可投标的页面解析
        private List <PdetailInfo> Read_Touzi(StreamReader xml)
        {
            HtmlDocument doc = new HtmlDocument();

            doc.Load(xml);
            //=========================================================================================
            List <PdetailInfo> pdetailInfoList = new List <PdetailInfo>();
            HtmlNodeCollection collection      = doc.DocumentNode.SelectNodes(@".//span[@class=""lb-kbsj""]/../../div/h3/a");

            if (collection != null)
            {
                foreach (HtmlNode node in collection)
                {
                    string att        = node.Attributes["href"].Value;
                    string PdetailURL = "https://www.16pu.com/" + att;

                    PdetailInfo pdetailInfo = Pdetail(PdetailURL);
                    pdetailInfoList.Add(pdetailInfo);
                }
            }
            return(pdetailInfoList);
        }
Exemplo n.º 5
0
        // <私有> 可投标的页面解析
        private PdetailInfo Read_Pdetail(StreamReader xml)
        {
            PdetailInfo pdetailInfo = new PdetailInfo();

            HtmlDocument doc = new HtmlDocument();

            doc.Load(xml);
            //=========================================================================================系统时间
            pdetailInfo.Systime = DateTime.Now;
            //=========================================================================================pid
            HtmlNode Node = doc.DocumentNode.SelectSingleNode(@".//input[@id=""cpbm""]");
            string   cpbm = Node.Attributes["value"].Value;

            pdetailInfo.ID  = cpbm;
            pdetailInfo.URL = @"https://www.16pu.com/pdetail" + cpbm + ".jhtml";
            //=========================================================================================标的编号
            Node = doc.DocumentNode.SelectSingleNode(@".//div[@class=""tit""]");
            if (Node != null)
            {
                string          InnerText = Node.InnerText.Trim();
                MatchCollection collec    = Regex.Matches(InnerText, @"(?<=日聚鑫\-)\w+");
                string          str       = collec[0].Value;
                pdetailInfo.Title = str;
            }
            //=========================================================================================年化收益
            Node = doc.DocumentNode.SelectSingleNode(@".//input[@id=""llje""]");
            string llje = Node.Attributes["value"].Value;

            Node = doc.DocumentNode.SelectSingleNode(@".//input[@id=""hbll""]");
            string hbll = Node.Attributes["value"].Value;

            pdetailInfo.Rate = Convert.ToDouble(llje) + Convert.ToDouble(hbll);

            //=========================================================================================期限
            Node = doc.DocumentNode.SelectSingleNode(@".//li[@class=""li-tzqx""]//span[@class=""szz""]");
            if (Node != null)
            {
                string InnerText = Node.InnerText.Trim();
                pdetailInfo.Term = Convert.ToInt16(InnerText);
            }

            //=========================================================================================开始时间
            Node = doc.DocumentNode.SelectSingleNode(@".//div[@class=""info-cont""]/ul/li[1]//following-sibling::text()[1]");
            if (Node != null)
            {
                string InnerText = Node.InnerText.Trim();
                pdetailInfo.StartTime = Convert.ToDateTime(InnerText);
            }
            //=========================================================================================结束时间
            Node = doc.DocumentNode.SelectSingleNode(@".//div[@class=""info-cont""]/ul/li[2]//following-sibling::text()[1]");
            if (Node != null)
            {
                string          InnerText = Node.InnerText.Trim();
                MatchCollection collec    = Regex.Matches(InnerText, @".*?(?=()");
                string          str       = collec[0].Value;
                pdetailInfo.EndTime = Convert.ToDateTime(str);
            }
            //=========================================================================================最小投资
            Node = doc.DocumentNode.SelectSingleNode(@".//input[@id=""zdqt""]");
            string zdqt = Node.Attributes["value"].Value;

            pdetailInfo.Minimum = Convert.ToDouble(zdqt);
            //=========================================================================================最小递增
            Node = doc.DocumentNode.SelectSingleNode(@".//input[@id=""dzed""]");
            string dzed = Node.Attributes["value"].Value;

            pdetailInfo.Increase = Convert.ToDouble(dzed);
            //=========================================================================================最大可投
            Node = doc.DocumentNode.SelectSingleNode(@".//input[@id=""zdkt""]");
            string zdkt = Node.Attributes["value"].Value;

            pdetailInfo.Maximum = Convert.ToDouble(zdkt);
            //=========================================================================================可用余额
            Node = doc.DocumentNode.SelectSingleNode(@".//em[@id=""dzzhkyye""]");
            if (Node != null)
            {
                string          InnerText = Node.InnerText.Trim();
                MatchCollection collec    = Regex.Matches(InnerText, @".*?(?=元)");
                string          str       = collec[0].Value;
                pdetailInfo.Balance = Convert.ToDouble(str);
            }
            //=========================================================================================剩余可投
            Node = doc.DocumentNode.SelectSingleNode(@".//input[@id=""sykt""]");
            string sykt = Node.Attributes["value"].Value;

            pdetailInfo.Amount = Convert.ToDouble(sykt);
            //=========================================================================================此刻时间(网页)
            Node = doc.DocumentNode.SelectSingleNode(@".//div[@id=""timec""]");
            string webtime = Node.Attributes["curDate"].Value;

            pdetailInfo.Webtime = Convert.ToDateTime(webtime);

            return(pdetailInfo);
        }
Exemplo n.º 6
0
        // 自动购买(检测标的+等待时间+购买成功)
        public bool AutoBuy()
        {
            List <PdetailInfo> pdetailInfo = new List <PdetailInfo>();

            while (true)
            {
                pdetailInfo = Touzi();
                if (pdetailInfo.Count == 0)
                {
                    Console.WriteLine("没有可投标的");
                    Thread.Sleep(30000);
                    continue;
                }
                Console.WriteLine("发现可投标的:\n==========================\n");
                Console.WriteLine(pdetailInfo[0].ToString());

                break;
            }
            PdetailInfo pdetail = pdetailInfo[0];


            //----------------------------------------------------------------测试用
            //PdetailInfo pdetail = new PdetailInfo();
            //pdetail.URL = @"https://www.16pu.com/pdetail13178.jhtml";
            //pdetail.ID = "13178";
            //pdetail.Title = "CG20171010128 ";
            //pdetail.Rate = 0.11;
            //pdetail.Term = 28;
            //pdetail.StartTime = Convert.ToDateTime("2017-10-14 23:20:25");
            //pdetail.EndTime = Convert.ToDateTime("2017-11-10");
            //pdetail.Minimum = 1000;
            //pdetail.Increase = 100;
            //pdetail.Maximum = 50000;
            //pdetail.Balance = 20000;
            //pdetail.Amount = 300000;
            //----------------------------------------------------------------
            if (pdetail.Balance == -1)
            {
                string logInfo = "";

                while (!Login(ref logInfo))
                {
                    Console.WriteLine(logInfo);
                }
                pdetail = Pdetail(pdetail.URL);
                Console.WriteLine(pdetail.ToString());
            }

            if (pdetail.Balance < pdetail.Minimum)
            {
                Console.WriteLine("可用金额小于最小投资金额");
                return(false);
            }

            double money = Math.Min(pdetail.Balance, Math.Min(pdetail.Maximum, pdetail.Amount));

            money = Math.Floor(money / 100) * 100;
            string   ID        = pdetail.ID;
            DateTime startTime = pdetail.StartTime;
            DateTime webTime   = pdetail.Webtime;
            DateTime sysTime   = pdetail.Systime;
            TimeSpan ts        = startTime - DateTime.Now - (webTime - sysTime);

            //double seconds = Math.Max(0, Math.Ceiling(ts.TotalSeconds));
            Console.WriteLine("投资标的{0},投资金额{1}元,将于{2}秒后投标", ID, money, Math.Ceiling(ts.TotalSeconds));

            //double s = seconds;
            while (Math.Ceiling(ts.TotalSeconds) > 0)
            {
                Console.WriteLine("倒计时{0}", Math.Ceiling(ts.TotalSeconds));
                if (ts.TotalSeconds == 60)
                {
                    string logInfo = "";
                    Login(ref logInfo);
                }
                Thread.Sleep(1000);
                ts = startTime - DateTime.Now - (webTime - sysTime);
            }

            Console.WriteLine("开始购买....");
            int reTry = 15;

            while (reTry > 0)
            {
                string r = Buy(money, ID);
                if (r == "OK")
                {
                    Console.WriteLine("购买成功!");
                    return(true);
                }
                else
                {
                    Console.WriteLine(r);
                    reTry = reTry - 1;
                    Thread.Sleep(300);
                }
            }

            return(false);
        }
Exemplo n.º 7
0
        // <私有> 可投标的页面解析
        private PdetailInfo Read_Pdetail(StreamReader xml)
        {
            PdetailInfo pdetailInfo = new PdetailInfo();

            HtmlDocument doc = new HtmlDocument();

            doc.Load(xml);
            //=========================================================================================
            HtmlNode Node = doc.DocumentNode.SelectSingleNode(@".//div[@class=""tit""]");

            if (Node != null)
            {
                string          InnerText = Node.InnerText.Trim();
                MatchCollection collec    = Regex.Matches(InnerText, @"(?<=日聚鑫\-)\w+");
                string          str       = collec[0].Value;
                pdetailInfo.Title = str;
            }
            //=========================================================================================
            HtmlNodeCollection collection = doc.DocumentNode.SelectNodes(@".//li[@class=""li-nhsy""]//span[@class=""sz""]");

            if (collection != null)
            {
                double i = 0;
                foreach (HtmlNode node in collection)
                {
                    string str_i = node.InnerText.Trim();
                    i = i + Convert.ToDouble(str_i);
                }
                pdetailInfo.Rate = i;
            }
            //=========================================================================================
            Node = doc.DocumentNode.SelectSingleNode(@".//li[@class=""li-tzqx""]//span[@class=""szz""]");
            if (Node != null)
            {
                string InnerText = Node.InnerText.Trim();
                pdetailInfo.Term = Convert.ToInt16(InnerText);
            }
            //=========================================================================================
            Node = doc.DocumentNode.SelectSingleNode(@".//div[@class=""info-cont""]/ul/li[1]//following-sibling::text()[1]");
            if (Node != null)
            {
                string InnerText = Node.InnerText.Trim();
                pdetailInfo.StartTime = Convert.ToDateTime(InnerText);
            }
            //=========================================================================================
            Node = doc.DocumentNode.SelectSingleNode(@".//div[@class=""info-cont""]/ul/li[2]//following-sibling::text()[1]");
            if (Node != null)
            {
                string          InnerText = Node.InnerText.Trim();
                MatchCollection collec    = Regex.Matches(InnerText, @".*?(?=()");
                string          str       = collec[0].Value;
                pdetailInfo.EndTime = Convert.ToDateTime(str);
            }
            //=========================================================================================
            Node = doc.DocumentNode.SelectSingleNode(@".//div[@class=""info-cont""]/ul/li[4]//following-sibling::text()[1]");
            if (Node != null)
            {
                string          InnerText = Node.InnerText.Trim();
                MatchCollection collec    = Regex.Matches(InnerText, @".*?(?=\s)");
                string          str       = collec[0].Value;
                pdetailInfo.Minimum = Convert.ToDouble(str);
            }
            //=========================================================================================
            Node = doc.DocumentNode.SelectSingleNode(@".//div[@class=""info-cont""]/ul/li[6]//following-sibling::text()[1]");
            if (Node != null)
            {
                string          InnerText = Node.InnerText.Trim();
                MatchCollection collec    = Regex.Matches(InnerText, @".*?(?=\s)");
                string          str       = collec[0].Value;
                pdetailInfo.Increase = Convert.ToDouble(str);
            }
            //=========================================================================================
            Node = doc.DocumentNode.SelectSingleNode(@".//div[@class=""kt-info""]/p[3]");
            if (Node != null)
            {
                string          InnerText = Node.InnerText.Trim();
                MatchCollection collec    = Regex.Matches(InnerText, @"(?<=:).*?(?=元)");
                string          str       = collec[0].Value;
                pdetailInfo.Maximum = Convert.ToDouble(str);
            }
            //=========================================================================================
            Node = doc.DocumentNode.SelectSingleNode(@".//em[@id=""dzzhkyye""]");
            if (Node != null)
            {
                string          InnerText = Node.InnerText.Trim();
                MatchCollection collec    = Regex.Matches(InnerText, @".*?(?=元)");
                string          str       = collec[0].Value;
                pdetailInfo.Balance = Convert.ToDouble(str);
            }
            //=========================================================================================
            Node = doc.DocumentNode.SelectSingleNode(@".//div[@class=""kt-info""]/p[2]//descendant::text()[1]");
            if (Node != null)
            {
                string          InnerText = Node.InnerText.Trim();
                MatchCollection collec    = Regex.Matches(InnerText, @"(?<=:).*?(?=元)");
                string          str       = collec[0].Value;
                pdetailInfo.Amount = Convert.ToDouble(str);
            }


            return(pdetailInfo);
        }