コード例 #1
0
 private void BtCongXia_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Cf_HttpWeb BaiDu_Web = new Cf_HttpWeb();
         BaiDu_Web.EncodingSet = "utf-8";
         string        searchweb    = BaiDu_Web.PostOrGet("http://music.baidu.com/search?key=" + Cf_PassWordClass.UrlEncode(TbSong.Text), HttpMethod.GET)[1];
         List <string> songlist     = Cf_String.ExtractString(searchweb, "<li data-songitem =", "</li>");
         List <string> songlistFilt = new List <string>();
         foreach (string str in songlist)
         {
             if (str.IndexOf("该资源来自其他网站") == -1)
             {
                 songlistFilt.Add(str);
             }
         }
         if (songlistFilt.Count == 0)
         {
             MessageBox.Show("没有这首歌可供下载", "", MessageBoxButton.OK, MessageBoxImage.Asterisk); return;
         }
         songlistFilt = Cf_String.LastListRemove(Cf_String.ListRemove(Cf_String.ListExtractString(songlistFilt, "sid", ","), 0, "sid&quot;:".Length), 0, 1);
         //以上获取要下载歌曲的字符串值
         List <string> cookie_6    = BaiDu_Web.PostOrGet("http://music.baidu.com/song/" + songlistFilt[0] + "/download?__o=%2Fsearch", HttpMethod.GET, cookie_5[0]);
         string        xcode       = Cf_String.LastStringRemove(Cf_String.ExtractString(cookie_6[1], "http://zhangmenshiting.baidu.com", "&")[0], 0, 1);
         WebClient     mywebclient = new WebClient();
         mywebclient.DownloadFile(xcode, System.Windows.Forms.Application.StartupPath + "\\" + TbSong.Text + ".mp3");
         MessageBox.Show("下载完毕", "", MessageBoxButton.OK, MessageBoxImage.Asterisk);
         TbSong.Clear();
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.Message, "", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
コード例 #2
0
        void BaiDuSongXiaZai()
        {
            Cf_HttpWeb BaiDu_Web = new Cf_HttpWeb();
            string     cookie_1  = BaiDu_Web.PostOrGet("http://www.baidu.com/", HttpMethod.GET)[0];

            stringBAIDUID       = Cf_String.LastStringRemove(Cf_String.ExtractString(cookie_1, "BAIDUID", ";")[0], 0, 1).Insert("BAIDUID=".Length, "\"") + "\"";
            stringH_PS_PSSID    = Cf_String.LastStringRemove(Cf_String.ExtractString(cookie_1, "H_PS_PSSID", ";")[0], 0, 1).Insert("H_PS_PSSID=".Length, "\"") + "\"";
            BaiDu_Web.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
            List <string> tokenlist = BaiDu_Web.PostOrGet("https://passport.baidu.com/v2/api/?getapi&tpl=mn&apiver=v3&tt=" + currenttime() + "&class=login&logintype=dialogLogin&callback=bd__cbs__gfhyis", HttpMethod.GET, stringBAIDUID + ";" + stringH_PS_PSSID);

            stringtoken = Cf_String.LastStringRemove(Cf_String.ExtractString(tokenlist[1], "token\" : \"", ",")[0].Remove(0, "token\" : \"".Length), 0, 2);
            //再次获取baiduid
            stringBAIDUID = Cf_String.LastStringRemove(Cf_String.ExtractString(tokenlist[0], "BAIDUID", ";")[0], 0, 1).Insert("BAIDUID=".Length, "\"") + "\"";
            List <string> list = BaiDu_Web.PostOrGet("https://passport.baidu.com/v2/api/?loginhistory&token=" + stringtoken + "&tpl=mn&apiver=v3&tt=" + currenttime() + "&callback=bd__cbs__gfhyis", HttpMethod.GET, stringBAIDUID + ";HOSUPPORT=1" + ";" + stringH_PS_PSSID);

            stringUBI = Cf_String.LastStringRemove(Cf_String.ExtractString(list[0], "UBI", ";")[0], 0, 1).Insert(4, "\"") + "\"";
            //再次获取baiduid
            stringBAIDUID = Cf_String.LastStringRemove(Cf_String.ExtractString(list[0], "BAIDUID", ";")[0], 0, 1).Insert("BAIDUID=".Length, "\"") + "\"";
            #region//POST提交数据
            string formdate = "charset=utf-8";
            formdate += "&token=" + stringtoken;
            formdate += "&tpl=mn";
            formdate += "&apiver=v3";
            formdate += "&tt=" + currenttime();
            formdate += "&codestring=";
            formdate += "&safeflg=0";
            formdate += "&u=" + "http://www.baidu.com/";
            formdate += "&isPhone=";
            formdate += "&quick_user=0";
            formdate += "&logintype=dialogLogin";
            formdate += "&logLoginType=pc_loginDialog";
            formdate += "&loginmerge=true";
            formdate += "&splogin=rate";
            formdate += "&username=jiang43605";
            formdate += "&password=jiang63020533";
            formdate += "&verifycode=";
            formdate += "&mem_pass=on";
            formdate += "&ppui_logintime=20339";
            formdate += "&callback=parent.bd__cbs__gfhyis";
            formdate += "&staticpage=http://www.baidu.com/cache/user/html/v3Jump.html";
            #endregion
            BaiDu_Web.UserDate    = formdate;
            BaiDu_Web.ContentType = "application/x-www-form-urlencoded";
            List <string> cookie_3 = BaiDu_Web.PostOrGet("https://passport.baidu.com/v2/api/?login", HttpMethod.POST, stringBAIDUID + ";HOSUPPORT=1" + ";" + stringH_PS_PSSID + ";" + stringUBI);
            stringyzm       = Cf_String.LastStringRemove(Cf_String.ExtractString(cookie_3[1], "captchaservice", "&")[0], 0, 1);
            ImCheack.Source = new BitmapImage(new Uri("https://passport.baidu.com/cgi-bin/genimage?" + stringyzm));
        }
コード例 #3
0
 /// <summary>
 /// ��������û���Ϣ
 /// </summary>
 /// <returns></returns>
 public List<UserInfo> GetAllUserInfoForAdmin()
 {
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8"; ;
     string url = "http://localhost:32839/api/restful/GetAllUserInfoForAdmin";
     string str = _httpweb.PostOrGet(url, HttpMethod.GET).HtmlValue;
     return JsonConvert.DeserializeObject<List<UserInfo>>(str);
 }
コード例 #4
0
 /// <summary>
 /// ע���˻�
 /// </summary>
 /// <param name="account"></param>
 /// <returns></returns>
 public ResponseMsg LogoutAccount(string account)
 {
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8"; ;
     string url = "http://localhost:32839/api/restful/UserInfo/LogoutAccount/" + account;
     string str = _httpweb.PostOrGet(url, HttpMethod.GET).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }
コード例 #5
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="userid"></param>
 /// <param name="sellid"></param>
 /// <returns></returns>
 public ResponseMsg AddOrderInfo(string userid, string sellid)
 {
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8";
     string url = string.Format("http://localhost:32839/api/restful/OrderInfo/AddOrderInfo/{0}/{1}", userid, sellid);
     string str = _httpweb.PostOrGet(url, HttpMethod.GET).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }
コード例 #6
0
 /// <summary>
 /// ע��
 /// </summary>
 /// <param name="account"></param>
 /// <param name="password"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public ResponseMsg RegisterAccount(string account, string password, string name)
 {
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8";
     string url = string.Format("http://localhost:32839/api/restful/Provider/RegisterAccount/{0}/{1}/{2}", account, password, name);
     string str = _httpweb.PostOrGet(url, HttpMethod.GET).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }
コード例 #7
0
 /// <summary>
 /// ɾ��
 /// </summary>
 /// <param name="orderId"></param>
 /// <returns></returns>
 public ResponseMsg DeleteOrderInfo(string orderId)
 {
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8";
     string url = "http://localhost:32839/api/restful/OrderInfo/DeleteOrderInfo/" + orderId;
     string str = _httpweb.PostOrGet(url, HttpMethod.GET).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }
コード例 #8
0
 /// <summary>
 /// ������ƷId���ظ���Ʒ����������
 /// </summary>
 /// <returns></returns>
 public List<ProductEvaluate> GetProductEvaluateByPdId(string pdid)
 {
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8";
     string url = string.Format("http://localhost:32839/api/restful/ProductEvaluate/GetProductEvaluateByPdId/{0}", pdid);
     string str = _httpweb.PostOrGet(url, HttpMethod.GET).HtmlValue;
     if (str.Contains("\"StatusCode\":0")) return null;
     return JsonConvert.DeserializeObject<List<ProductEvaluate>>(str);
 }
コード例 #9
0
 /// <summary>
 /// �����û�id��ѯ����
 /// </summary>
 /// <param name="userid"></param>
 /// <returns></returns>
 public List<OrderInfo> GetOrderInfoByUserId(string userid)
 {
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8";
     string url = "http://localhost:32839/api/restful/OrderInfo/GetOrderInfo/" + userid;
     string str = _httpweb.PostOrGet(url, HttpMethod.GET).HtmlValue;
     if (str.Contains("\"StatusCode\":0")) return null;
     return JsonConvert.DeserializeObject<List<OrderInfo>>(str);
 }
コード例 #10
0
 /// <summary>
 /// ����account����û�
 /// </summary>
 /// <param name="account"></param>
 /// <returns></returns>
 public UserInfo GetUserInfoByAccount(string account)
 {
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8"; ;
     string url = string.Format("http://localhost:32839/api/restful/UserInfo/GetUserInfoByAccount/{0}", account);
     string str = _httpweb.PostOrGet(url, HttpMethod.GET).HtmlValue;
     if (str.Contains("\"StatusCode\":0")) return null;
     return JsonConvert.DeserializeObject<UserInfo>(str);
 }
コード例 #11
0
 public ResponseMsg CreatAccount(string account, string password)
 {
     if (ApiV.IsNull(account, password)) return ApiV.EMsg();
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8"; ;
     string url = string.Format("http://localhost:32839/api/restful/UserInfo/CreatAccount/{0}/{1}", account, password);
     string str = _httpweb.PostOrGet(url, HttpMethod.GET).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }
コード例 #12
0
 /// <summary>
 /// �û�����һ����Ʒ������Post����
 /// </summary>
 /// <param name="userid"></param>
 /// <returns></returns>
 public ResponseMsg ReleaseBuyInfo(Guid userid, string Describe, DateTime DurationTime, string RequireProduceName)
 {
     BuyInfo newBuyInfo = new BuyInfo
     {
         Describe = Describe,
         DurationTime = DurationTime,
         RequireProduceName = RequireProduceName,
     };
     Cf_HttpWeb _httpweb = new Cf_HttpWeb
     {
         ContentType = "text/html",
         UserDate = JsonConvert.SerializeObject(newBuyInfo)
     };
     _httpweb.EncodingSet = "utf-8";
     string url = "http://localhost:32839/api/restful/BuyInfo/ReleaseBuyInfo/" + userid.ToString();
     string str = _httpweb.PostOrGet(url, HttpMethod.POST).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }
コード例 #13
0
 /// <summary>
 /// ���һ����Ʒ���ݹ�Ӧ��ID��ʹ��Post(json)
 /// </summary>
 /// <param name="providerid"></param>
 /// <param name="PdName"></param>
 /// <param name="ProductDescribe"></param>
 /// <returns></returns>
 public ResponseMsg AddProduct(Guid providerid, string PdName, string ProductDescribe,float price,int num)
 {
     ProductInfo productInfo = new ProductInfo
     {
         PdNum = num,
         PdPrice = price,
         PdName = PdName,
         ProductDescribe = ProductDescribe
     };
     Cf_HttpWeb _httpweb = new Cf_HttpWeb
     {
         ContentType = "text/html",
         UserDate = JsonConvert.SerializeObject(productInfo)
     };
     _httpweb.EncodingSet = "utf-8";
     string url = string.Format("http://localhost:32839/api/restful/ProductInfo/AddProduct/{0}", providerid.ToString());
     string str = _httpweb.PostOrGet(url, HttpMethod.POST).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }
コード例 #14
0
 /// <summary>
 /// ���һ����Ʒ���ۣ�ʹ��Post(json)
 /// </summary>
 /// <returns></returns>
 public ResponseMsg AddProductEvaluate(Guid pdid, string item, Guid userid)
 {
     ProductEvaluate productEvaluate = new ProductEvaluate
     {
         PdId = pdid,
         UserId = userid,
         EvaTime = DateTime.Now,
         SubTime = DateTime.Now
     };
     Cf_HttpWeb _httpweb = new Cf_HttpWeb
     {
         ContentType = "text/html",
         UserDate = JsonConvert.SerializeObject(productEvaluate)
     };
     _httpweb.EncodingSet = "utf-8";
     const string url = "http://localhost:32839/api/restful/ProductEvaluate/AddProductEvaluate";
     string str = _httpweb.PostOrGet(url, HttpMethod.POST).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }
コード例 #15
0
 /// <summary>
 /// �޸�
 /// </summary>
 /// <returns></returns>
 public ResponseMsg UpdataBuyInfo(string buyid, string name, string describe, string durationtime)
 {
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8";
     string url = string.Format("http://localhost:32839/api/restful/BuyInfo/UpdataBuyInfo/{0}/{1}/{2}/{3}", buyid, name, describe, durationtime);
     string str = _httpweb.PostOrGet(url, HttpMethod.GET).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }
コード例 #16
0
        void BaiDuLogin()
        {
            Cf_HttpWeb BaiDu_Web = new Cf_HttpWeb();

            #region//POST提交数据
            string formdate = "charset=utf-8";
            formdate += "&token=" + stringtoken;
            formdate += "&tpl=mn";
            formdate += "&apiver=v3";
            formdate += "&tt=" + currenttime();
            formdate += "&codestring=" + stringyzm;
            formdate += "&safeflg=0";
            formdate += "&u=" + "http://www.baidu.com/";
            formdate += "&isPhone=";
            formdate += "&quick_user=0";
            formdate += "&logintype=dialogLogin";
            formdate += "&logLoginType=pc_loginDialog";
            formdate += "&loginmerge=true";
            formdate += "&splogin=rate";
            formdate += "&username=jiang43605";
            formdate += "&password=jiang63020533";
            formdate += "&verifycode=" + TbInput.Text;
            formdate += "&mem_pass=on";
            formdate += "&ppui_logintime=20339";
            formdate += "&callback=parent.bd__cbs__gfhyis";
            formdate += "&staticpage=http://www.baidu.com/cache/user/html/v3Jump.html";
            #endregion
            BaiDu_Web.UserDate    = formdate;
            BaiDu_Web.ContentType = "application/x-www-form-urlencoded";
            List <string> cookie_4 = BaiDu_Web.PostOrGet("https://passport.baidu.com/v2/api/?login", HttpMethod.POST, stringBAIDUID + ";HOSUPPORT=1" + ";" + stringH_PS_PSSID + ";" + stringUBI);
            string        param    = Cf_String.LastStringRemove(Cf_String.ExtractString(cookie_4[1], "Param", "&")[0], 0, 1).Remove(0, "Param=".Length);
            try
            {
                cookie_5 = BaiDu_Web.PostOrGet("http://user.hao123.com/static/crossdomain.php?bdu=" + param + "&t=" + currenttime(), HttpMethod.GET, cookie_4[0]);
                BaiDu_Web.EncodingSet = "utf-8";
                string        searchweb    = BaiDu_Web.PostOrGet("http://music.baidu.com/search?key=" + Cf_PassWordClass.UrlEncode(TbSong.Text), HttpMethod.GET)[1];
                List <string> songlist     = Cf_String.ExtractString(searchweb, "<li data-songitem =", "</li>");
                List <string> songlistFilt = new List <string>();
                foreach (string str in songlist)
                {
                    if (str.IndexOf("该资源来自其他网站") == -1)
                    {
                        songlistFilt.Add(str);
                    }
                }
                if (songlistFilt.Count == 0)
                {
                    MessageBox.Show("没有这首歌可供下载", "", MessageBoxButton.OK, MessageBoxImage.Asterisk); return;
                }
                songlistFilt = Cf_String.LastListRemove(Cf_String.ListRemove(Cf_String.ListExtractString(songlistFilt, "sid", ","), 0, "sid&quot;:".Length), 0, 1);
                List <string> cookie_6    = BaiDu_Web.PostOrGet("http://music.baidu.com/song/" + songlistFilt[0] + "/download?__o=%2Fsearch", HttpMethod.GET, cookie_5[0]);
                string        xcode       = Cf_String.LastStringRemove(Cf_String.ExtractString(cookie_6[1], "http://zhangmenshiting.baidu.com", "&")[0], 0, 1);
                WebClient     mywebclient = new WebClient();
                mywebclient.DownloadFile(xcode, System.Windows.Forms.Application.StartupPath + "\\" + TbSong.Text + ".mp3");
                MessageBox.Show("下载完毕", "", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                TbSong.Clear();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message, "", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #17
0
 /// <summary>
 /// �޸��˻���Ϣ���봫��Post���ݣ�Json��
 /// </summary>
 /// <returns></returns>
 public ResponseMsg UpdataAccount(int? age, string name, string phone, bool? sex)
 {
     Cf_HttpWeb _httpweb = new Cf_HttpWeb();
     _httpweb.EncodingSet = "utf-8"; ;
     UserInfo userInfo = new UserInfo
     {
         Age = age,
         Name = name,
         Phone = phone,
         Sex = sex
     };
     _httpweb.ContentType = "text/html";
     _httpweb.UserDate = JsonConvert.SerializeObject(userInfo);
     string url = "http://localhost:32839/api/restful/UserInfo/UpdataAccount";
     string str = _httpweb.PostOrGet(url, HttpMethod.POST).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }
コード例 #18
0
 /// <summary>
 /// ����json�����޸�
 /// </summary>
 /// <returns></returns>
 public ResponseMsg UpdataProduct(Guid pdid, string pdName, double pdPrice, string productDescribe, int pdNum)
 {
     ProductInfo productInfo = new ProductInfo
     {
         PdId = pdid,
         PdName = pdName,
         PdPrice = pdPrice,
         ProductDescribe = productDescribe,
         PdNum = pdNum
     };
     Cf_HttpWeb _httpweb = new Cf_HttpWeb
     {
         ContentType = "text/html",
         UserDate = JsonConvert.SerializeObject(productInfo)
     };
     _httpweb.EncodingSet = "utf-8";
     string url = "http://localhost:32839/api/restful/ProductInfo/UpdataProduct";
     string str = _httpweb.PostOrGet(url, HttpMethod.POST).HtmlValue;
     return JsonConvert.DeserializeObject<ResponseMsg>(str);
 }