Beispiel #1
0
        internal void 准备发货(string sID)
        {
            HeaderObject hobDetail = new HeaderObject();
            hobDetail.CookieStr = _CookieStr;
            hobDetail.Url = "https://www.jiaoyimao.com/merchant/deliver/prepareIosPrechargeOrder/" + sID;
            HttpHelper.Get(hobDetail);

            hobDetail = new HeaderObject();
            hobDetail.CookieStr = _CookieStr;
            hobDetail.Url = "https://www.jiaoyimao.com/merchant/deliver/actViewIosPrechargeOrder/" + sID;
            string r = HttpHelper.Get(hobDetail);
        }
Beispiel #2
0
        /// <SUMMARY></SUMMARY> 
        /// 获取指定页面的HTML代码 
        /// 
        /// <PARAM name="url" />指定页面的路径 
        /// <PARAM name="postData" />回发的数据 
        /// <PARAM name="isPost" />是否以post方式发送请求 
        /// <PARAM name="cookieCollection" />Cookie集合 
        /// <RETURNS></RETURNS> 
        public static string Get(HeaderObject HObject)
        {
            HttpWebRequest httpWebRequest = null;
            HttpWebResponse httpWebResponse = null;
            try
            {
                httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(HObject.Url);

                httpWebRequest.Headers.Add("Cookie", HObject.CookieStr);

                httpWebRequest.Headers.Add("Cache-control", "no-cache");
                httpWebRequest.Headers.Add("Accept-Language", "zh-cn");

                httpWebRequest.CookieContainer = HObject.CookieContainer;
                httpWebRequest.TransferEncoding = "";
                httpWebRequest.ContentType = HObject.ContentType;
                httpWebRequest.AllowAutoRedirect = true;
                //httpWebRequest.ServicePoint.ConnectionLimit = maxTry;
                httpWebRequest.Referer = HObject.Referer;
                httpWebRequest.Accept = HObject.Accept;
                httpWebRequest.UserAgent = HObject.UserAgent;
                httpWebRequest.Method = "GET";
                //httpWebRequest.ContentLength = byteRequest.Length;

                httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();

                Stream responseStream = httpWebResponse.GetResponseStream();
                StreamReader streamReader = new StreamReader(responseStream, HObject.Encoding);
                string html = streamReader.ReadToEnd();
                streamReader.Close();
                responseStream.Close();

                httpWebRequest.Abort();
                httpWebResponse.Close();

                return html;
            }
            catch (Exception e)
            {
                //Console.ForegroundColor = ConsoleColor.Red;
                //Console.WriteLine(DateTime.Now.ToString("HH:mm:ss ") + e.Message);
                //Console.ForegroundColor = ConsoleColor.White;

                if (httpWebRequest != null)
                {
                    httpWebRequest.Abort();
                } if (httpWebResponse != null)
                {
                    httpWebResponse.Close();
                }
                return string.Empty;
            }
        }
Beispiel #3
0
        public static string Post(HeaderObject HObject, string AParam)
        {
            HttpWebRequest httpWebRequest = null;
            HttpWebResponse httpWebResponse = null;
            try
            {
                httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(HObject.Url);

                httpWebRequest.Headers.Add("Cookie", HObject.CookieStr);

                httpWebRequest.Headers.Add("Cache-control", "no-cache");
                httpWebRequest.Headers.Add("Accept-Language", "zh-cn");
                //httpWebRequest.Headers.Add("x-requested-with", "XMLHttpRequest");

                httpWebRequest.CookieContainer = HObject.CookieContainer;
                httpWebRequest.TransferEncoding = "";
                httpWebRequest.ContentType = HObject.ContentType;
                httpWebRequest.AllowAutoRedirect = true;
                //httpWebRequest.ServicePoint.ConnectionLimit = maxTry;
                httpWebRequest.Referer = HObject.Referer;
                httpWebRequest.Accept = HObject.Accept;
                httpWebRequest.UserAgent = HObject.UserAgent;
                httpWebRequest.Method = "POST";
                //httpWebRequest.ContentLength = byteRequest.Length;

                byte[] postBytes = Encoding.ASCII.GetBytes(AParam);

                httpWebRequest.ContentLength = postBytes.Length;

                using (Stream reqStream = httpWebRequest.GetRequestStream())  //填参数
                {
                    reqStream.Write(postBytes, 0, postBytes.Length);
                }

                string html = "";
                using (WebResponse wr = httpWebRequest.GetResponse())  //Post
                {
                    HttpWebResponse rs = (HttpWebResponse)wr;
                    StreamReader reader = new StreamReader(wr.GetResponseStream(), HObject.Encoding);
                    html = reader.ReadToEnd();
                }

                if (httpWebRequest != null)
                {
                    httpWebRequest.Abort();
                } if (httpWebResponse != null)
                {
                    httpWebResponse.Close();
                }

                return html;
            }
            catch (Exception e)
            {
                //Console.ForegroundColor = ConsoleColor.Red;
                //Console.WriteLine(DateTime.Now.ToString("HH:mm:ss ") + e.Message);
                //Console.ForegroundColor = ConsoleColor.White;

                if (httpWebRequest != null)
                {
                    httpWebRequest.Abort();
                } if (httpWebResponse != null)
                {
                    httpWebResponse.Close();
                }
                return string.Empty;
            }
        }
Beispiel #4
0
        internal void 发货(string sID)
        {
            准备发货(sID);

            string sParam = "orderId=" + sID + "&chargeRemark=";

            HeaderObject hobDetail = new HeaderObject();
            hobDetail.CookieStr = _CookieStr;
            hobDetail.Url = "https://www.jiaoyimao.com/merchant/deliver/submitactiosprechargeorder";
            string sResult = HttpHelper.Post(hobDetail, sParam);
        }
Beispiel #5
0
        internal string 获取订单详情(string sID)
        {
            HeaderObject hobDetail = new HeaderObject();
            hobDetail.CookieStr = _CookieStr;
            hobDetail.Url = "https://www.jiaoyimao.com/merchant/deliver/actViewIosPrechargeOrder/" + sID;
            string sResult = HttpHelper.Get(hobDetail);

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

            HtmlNode rootnode = doc.DocumentNode;    //XPath路径表达式,这里表示选取所有span节点中的font最后一个子节点,其中span节点的class属性值为num
            //根据网页的内容设置XPath路径表达式
            //string xpathstring = "//div[@class='MsgContentSelf'or@class='MsgContent']";
            string xpathstring = "//div[@class='row']";
            HtmlNodeCollection msghcon = rootnode.SelectNodes(xpathstring);    //所有找到的节点都是一个集合
            if (msghcon == null)
                return "";
            //MessageBox.Show(msghcon[0].InnerText);

            string sTem = string.Empty;
            string ret="";

            ret+="[ID:" + sID+"]\r\n";
            sTem = 截取文本(sResult, "订单号:", "</div>", 0);
            ret += "订单号:" + sTem + "\r\n";
            foreach (HtmlNode hnitem in msghcon)
            {
                ret += hnitem.InnerText.Replace("&yen;", "") + "\r\n";
            }
            return ret;
        }
Beispiel #6
0
        internal ArrayList 获取订单列表()
        {
            HeaderObject HObject = new HeaderObject();
            HObject.CookieStr = _CookieStr;
            HObject.Url = "https://www.jiaoyimao.com/merchant/deliver/manageIosPrechargeOrder?page=1&listType=1";
            string sResult = HttpHelper.Get(HObject);

            //textBox1.Text = sResult;

            //Get total pagecount 共1页
            //string sTem = GetPosValue(sResult, "mod-page", "</div>", 0);
            string sTem = 截取文本(sResult, "共", "页 ,到第", 0);
            int iTotalPage = ConvertToInt32(sTem, 1);
            ArrayList dd = new ArrayList();
            dd = 解析订单列表(sResult, dd);

            for (int i = 2; i <= iTotalPage; i++)
            {
                HObject.CookieStr = _CookieStr;
                HObject.Url = string.Format("https://www.jiaoyimao.com/merchant/deliver/manageIosPrechargeOrder?page={0}&listType=1", i);
                sResult = HttpHelper.Get(HObject);
                dd = 解析订单列表(sResult, dd);
            }
            return dd;
        }
Beispiel #7
0
        internal bool 登录()
        {
            //string url = "https://api.open.uc.cn/cas/login/commit?uc_param_str=einisivelafrpfmibiup";
            string sUrl = "https://api.open.uc.cn/cas/login/commit";
            HttpWebRequest httpRequest = WebRequest.Create(sUrl) as HttpWebRequest;
            //httpRequest.ServicePoint.Expect100Continue = false;
            httpRequest.AllowAutoRedirect = true;
            httpRequest.KeepAlive = true;
            //httpRequest.CookieContainer = GlobalUnit.CookieCAli;
            httpRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)";
            httpRequest.ContentType = "application/x-www-form-urlencoded";
            httpRequest.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*";
            //httpRequest.Referer = "https://login.taobao.com/member/login.jhtml?style=b2b&from=b2b&full_redirect=true&redirect_url=http%3A%2F%2Floginchina.alibaba.com%2Fmember%2Fjump.htm%3Ftarget%3Dhttp%253A%252F%252Floginchina.alibaba.com%252Fmember%252FmarketSigninJump.htm%253FDone%253Dhttp%25253A%25252F%25252Fchina.alibaba.com%25252F&reg=http%3A%2F%2Fchina.alibaba.com%2Fmember%2Fjoin.htm%3Flead%3Dhttp%253A%252F%252Fchina.alibaba.com%252F%26leadUrl%3Dhttp%253A%252F%252Fchina.alibaba.com%252F%26tracelog%3Dnotracelog_s_reg";
            httpRequest.Method = "POST";
            //httpRequest.Headers.Add("Accept-Encoding", "");
            httpRequest.Headers.Add("Cache-Control", "no-cache");
            //httpRequest.Headers.Add("Cookie", GlobalUnit.CookiesAli);

            //Encoding myEncoding = Encoding.GetEncoding("gb2312");
            Encoding myEncoding = Encoding.GetEncoding("utf-8");
            httpRequest.CookieContainer = _CookieCAli;

            //Parameter Name	Value
            //client_id	94
            //redirect_uri	https://www.jiaoyimao.com/login?redirectUrl=https%3A%2F%2Fwww.jiaoyimao.com%2Fmerchant%2Fadmin%2Findex
            //target_client_id
            //target_redirect_uri
            //display	pc
            //change_uid	1
            //loginName	wushehe004
            //password	wu456123

            //ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
            //ServicePointManager.ServerCertificateValidationCallback =
            //            new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);

            string param =

                "client_id=94&" +
                "redirect_uri=" + HttpUtility.UrlEncode("https://www.jiaoyimao.com/login?redirectUrl=https%3A%2F%2Fwww.jiaoyimao.com%2Fmerchant%2Fadmin%2Findex", myEncoding) + "&" +
                "target_client_id=&" +
                "target_redirect_uri=&" +
                "display=pc&" +
                "change_uid=1&" +
                "loginName=" + 账号 + "&" +
                "password="******"";
            foreach (var item in CookieList)
            {
                //item.Domain = ".china.alibaba.com";
                //text_Result.AppendText("======" + item.Value);
                htable.Add(item.Name, item.Value);
                _CookieStr += item.Name + "=" + item.Value + "; ";
            }

            //获取csrf_token
            HeaderObject HObject = new HeaderObject();
            HObject.CookieStr = _CookieStr;
            HObject.Url = "https://www.jiaoyimao.com/merchant/staff/index";
            sResult = HttpHelper.Get(HObject);

            if (sResult.IndexOf("商家管理后台") > 0)
            {
                IsLogin = true;
                return true;
            }
            else
            {
                IsLogin = false;
                return false;
            }

            //MessageBox.Show(sResult);
        }