Beispiel #1
0
 private bool VerIP(string ip, int port)
 {
     try
     {
         HttpWebRequest  Req;
         HttpWebResponse Resp;
         WebProxy        proxyObject = new WebProxy(ip, port); // port为端口号 整数型
         Req         = WebRequest.Create("https://www.baidu.com") as HttpWebRequest;
         Req.Proxy   = proxyObject;                            //设置代理
         Req.Timeout = 1000;                                   //超时
         Resp        = (HttpWebResponse)Req.GetResponse();
         Encoding bin = Encoding.GetEncoding("UTF-8");
         using (StreamReader sr = new StreamReader(Resp.GetResponseStream(), bin))
         {
             string str = sr.ReadToEnd();
             if (str.Contains("百度"))
             {
                 Resp.Close();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Beispiel #2
0
        public bool VerIP(string address)
        {
            try
            {
                HttpWebRequest  Req;
                HttpWebResponse Resp;
                WebProxy        proxyObject = new WebProxy(address); // port为端口号 整数型
                Req       = WebRequest.Create("https://www.baidu.com") as HttpWebRequest;
                Req.Proxy = proxyObject;                             //设置代理
                string proxyUser = "******";
                string proxyPass = "******";


                Req.Proxy.Credentials = new System.Net.NetworkCredential(proxyUser, proxyPass);
                Req.Timeout           = 500; //超时

                using (Resp = (HttpWebResponse)Req.GetResponse())
                {
                    if (Resp.StatusCode == HttpStatusCode.OK)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #3
0
 /// <summary>
 /// 通过登录访问    登录访问失败,账号请求过多被锁,访问403
 /// </summary>
 /// <param name="url">访问地址</param>
 /// <param name="html">得到的html字符串</param>
 static void getHtmlByCookie(string url, ref string html)
 {
     try
     {
         HttpWebRequest  Req;
         HttpWebResponse Resp;
         Req         = WebRequest.Create(url) as HttpWebRequest;
         Req.Timeout = 8000;   //超时
         Req.Headers.Add("Cookie", cookie);
         Req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36";
         Resp          = (HttpWebResponse)Req.GetResponse();
         Encoding bin = Encoding.GetEncoding("UTF-8");
         using (StreamReader sr = new StreamReader(Resp.GetResponseStream(), bin))
         {
             string str = sr.ReadToEnd();
             if (str.Contains("异常"))
             {
                 Console.WriteLine("");
             }
             else
             {
                 html = str;
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Beispiel #4
0
            /// <summary>
            /// 搜索函数
            /// </summary>
            /// <param name="Query">必选,关键字</param>
            /// <param name="PageNumber">可选,页码,默认为1</param>
            /// <param name="PageSize">可选,每页数据条数,默认为20</param>
            /// <returns>结果</returns>
            public static ResultData Search(string Query, int PageNumber = 1, int PageSize = 10)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    Req = (HttpWebRequest)WebRequest.Create(@"http://search.5sing.kugou.com/home/json?keyword=" + HttpUtility.UrlEncode(Query, Encoding.UTF8) + "&sort=1&page=" + PageNumber + "&filter=0&type=0");
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    str = str.Replace("<em class=\\\\\\\"keyword\\\\\\\">", "").Replace("<\\/em>", "");
                    JObject    p      = JObject.Parse(str);
                    ResultData Result = new ResultData {
                        List1 = new List <SongListItem>()
                    };
                    Result.Tot = int.Parse(p["pageInfo"]["totalCount"].ToString());
                    foreach (var songinfo in p["list"])
                    {
                        SongListItem SLI = new SongListItem {
                            Album1 = "", Singer1 = songinfo["singer"].ToString(), SongId1 = songinfo["songId"].ToString(), SongName1 = songinfo["songName"].ToString(), Lrc1 = "", Quality1 = new QualityList(), Pic1 = new SongPic(), SongInterval1 = ""
                        };
                        SLI.Quality1.Qother = true;
                        SLI.Quality1.Sother = songinfo["songSize"].ToString();
                        SLI.Quality1.Fother = songinfo["typeEname"].ToString() + "-" + songinfo["songId"].ToString();
                        Result.List1.Add(SLI);
                    }
                    return(Result);
                }
                catch (Exception ex)
                {
                    return(new ResultData());
                }
            }
Beispiel #5
0
 /// <summary>
 /// 歌词迷歌词来源
 /// </summary>
 /// <param name="SongName">必选,歌名</param>
 /// <param name="Singer">可选,歌手名,默认为空</param>
 /// <returns>歌词结果列表</returns>
 public static List <LrcResult> GeCiMiLrc(string SongName, string Singer = "")
 {
     try
     {
         List <LrcResult> rs = new List <LrcResult>();
         HttpWebRequest   Req;
         HttpWebResponse  Rep;
         if (Singer != "")
         {
             Req = (HttpWebRequest)WebRequest.Create(@"http://geci.me/api/lyric/" + HttpUtility.UrlEncode(SongName, Encoding.UTF8) + "/" + HttpUtility.UrlEncode(Singer, Encoding.UTF8));
         }
         else
         {
             Req = (HttpWebRequest)WebRequest.Create(@"http://geci.me/api/lyric/" + HttpUtility.UrlEncode(SongName, Encoding.UTF8));
         }
         Req.Timeout = 300000;
         Rep         = (HttpWebResponse)Req.GetResponse();
         StreamReader Reader = new StreamReader(Rep.GetResponseStream());
         string       str    = Reader.ReadToEnd();
         JObject      p      = JObject.Parse(str);
         foreach (var songinfo in p["result"])
         {
             string url      = songinfo["lrc"].ToString();
             string songname = UnicodeToGB(songinfo["song"].ToString());
             rs.Add(new LrcResult {
                 SongName = songname, Singer = Singer, Album = "", url = url, Relook = ""
             });
         }
         return(rs);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #6
0
 /// <summary>
 /// 百度音乐歌词搜索
 /// </summary>
 /// <param name="Query">必选,关键词</param>
 /// <param name="pn">可选,页码,默认为1</param>
 /// <returns>歌词结果列表</returns>
 public static List <LrcResult> BaiduLrc(string Query, int pn = 1)
 {
     try
     {
         List <LrcResult> rs = new List <LrcResult>();
         HttpWebRequest   Req;
         HttpWebResponse  Rep;
         Req = (HttpWebRequest)WebRequest.Create(@"http://music.baidu.com/search/lrc?key=" + HttpUtility.UrlEncode(Query, Encoding.UTF8) + @"&start=" + (20 * (pn - 1)).ToString());
         Rep = (HttpWebResponse)Req.GetResponse();
         StreamReader Reader = new StreamReader(Rep.GetResponseStream());
         string       str    = Reader.ReadToEnd();
         string[]     tmp    = Regex.Split(str, "<div class=\"song-content\">");
         for (int i = 1; i < tmp.Length; i++)
         {
             string songname = Regex.Split(Regex.Split(Regex.Split(Regex.Split(tmp[i], "<span class=\"song-title\">歌曲:")[1], "</span>")[0], "</a>")[0], "\">")[1].Replace("<em>", "").Replace("</em>", "").Replace("\t", "").Replace("\n", "");
             string singer   = Regex.Split(Regex.Split(tmp[i], "<span class=\"artist-title\">歌手:")[1], ">")[2].Replace("<em>", "").Replace("</em>", "").Replace("</a", "");
             string album    = Regex.Split(Regex.Split(tmp[i], "<span class=\"album-title\">")[1].Replace("<em>", "").Replace("</em>", ""), ">")[1].Replace("</a", "");
             string url      = @"http://music.baidu.com" + Regex.Split(Regex.Split(tmp[i], "<a class=\"down-lrc-btn { 'href':'")[1], "' }\" href=\"#\">下载LRC歌词</a>")[0];
             string relook   = Regex.Split(Regex.Split(Regex.Split(tmp[i], "<p id=\"lyricCont-")[1], "</p>")[0].Replace("<em>", "").Replace("</em>", "").Replace("<br />", "\r\n"), ">")[1];
             rs.Add(new LrcResult {
                 SongName = songname, Singer = singer, Album = album, url = url, Relook = relook
             });
         }
         return(rs);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #7
0
 bool yanzhen(string ipStr, int port)
 {
     try
     {
         HttpWebRequest  Req;
         HttpWebResponse Resp;
         WebProxy        proxyObject = new WebProxy(ipStr, port); // port为端口号 整数型
         Req         = WebRequest.Create("http://www.baidu.com/s?wd=ip&ie=utf-8&tn=94523140_hao_pg") as HttpWebRequest;
         Req.Proxy   = proxyObject;                               //设置代理
         Req.Timeout = 1000;                                      //超时
         Resp        = (HttpWebResponse)Req.GetResponse();
         Encoding bin = Encoding.GetEncoding("UTF-8");
         using (StreamReader sr = new StreamReader(Resp.GetResponseStream(), bin))
         {
             string str = sr.ReadToEnd();
             if (str.Contains(ipStr))
             {
                 Resp.Close();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(false);
     }
 }
Beispiel #8
0
 /// <summary>
 /// QQ音乐歌词搜索
 /// </summary>
 /// <param name="Query">必选,关键词</param>
 /// <param name="pn">可选,页码,默认为1</param>
 /// <param name="ps">可选,页码,默认为20</param>
 /// <returns></returns>
 public static List <LrcResult> QQMusicLrc(string Query, int pn = 1, int ps = 20)
 {
     try
     {
         List <LrcResult> rs = new List <LrcResult>();
         HttpWebRequest   Req;
         HttpWebResponse  Rep;
         Req = (HttpWebRequest)WebRequest.Create(@"http://c.y.qq.com/soso/fcgi-bin/search_cp?remoteplace=txt.yqq.center&format=json&t=7&p=" + pn + "&n=" + ps + "&w=" + HttpUtility.UrlEncode(Query, Encoding.UTF8));
         Rep = (HttpWebResponse)Req.GetResponse();
         StreamReader Reader = new StreamReader(Rep.GetResponseStream());
         string       str    = Reader.ReadToEnd();
         JObject      p      = JObject.Parse(str);
         foreach (var songinfo in p["data"]["lyric"]["list"])
         {
             string _singer = "";
             foreach (var singer in songinfo["singer"])
             {
                 _singer = _singer + "," + singer["name"].ToString();
             }
             _singer = _singer.Substring(0, _singer.Length - 1);
             string url      = "http://music.qq.com/miniportal/static/lyric/" + songinfo["songid"].ToString().Substring(songinfo["songid"].ToString().Length - 2, 2).Replace("0", "") + "/" + songinfo["songid"].ToString() + ".xml";
             string relook   = songinfo["content"].ToString().Replace("&lt;strong class=&quot;keyword&quot;&gt;", "").Replace("&lt;/strong&gt;", "").Replace("&lt;br/&gt;", "\r\n").Replace("&#39;", "'").Replace("&apos;", "'");
             string songname = songinfo["songname"].ToString();
             string album    = songinfo["albumname"].ToString();
             rs.Add(new LrcResult {
                 SongName = songname, Singer = _singer, Album = album, url = url, Relook = relook
             });
         }
         return(rs);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #9
0
            /// <summary>
            /// 获取歌曲文件(播放专用)
            /// </summary>
            /// <param name="SongId">歌曲ID</param>
            /// <param name="Quanlity">音质</param>
            /// <returns>歌曲地址</returns>
            public static string GetSong(string SongId, string Quanlity)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    byte[] param = Encoding.UTF8.GetBytes("param=" + Convert.ToBase64String(Encoding.UTF8.GetBytes("{\"key\":\"" + SongId + "\",\"rate\":\"128,192,256,320,flac\",\"linkType\":0,\"isCloud\":0,\"version\":\"10.1.8.3\"}")));
                    Req             = (HttpWebRequest)WebRequest.Create(@"http://musicmini2014.baidu.com/2016/app/link/getLinks.php");
                    Req.Method      = "POST";
                    Req.ContentType = "application/x-www-form-urlencoded";
                    Req.UserAgent   = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.2; WOW64; Trident/7.0)";
                    Stream reqstream = Req.GetRequestStream();
                    reqstream.Write(param, 0, param.Length);
                    reqstream.Close();
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader       = new StreamReader(Rep.GetResponseStream());
                    string       str          = Reader.ReadToEnd();
                    JObject      p            = JObject.Parse(str);
                    string[]     Songfilelist = Regex.Split(p["file_list"].ToString().Replace("[", "").Replace("]", "").Replace("\r\n", "").Replace(" ", ""), "},{");
#pragma warning disable CS0162 // 检测到无法访问的代码
                    for (int i = 0; i < Songfilelist.Length; i++)
#pragma warning restore CS0162 // 检测到无法访问的代码
                    {
                        if (i != 0 && i != Songfilelist.Length - 1)
                        {
                            Songfilelist[i] = "{" + Songfilelist[i] + "}";
                        }
                        else
                        {
                            if (i == 0 && i != Songfilelist.Length - 1)
                            {
                                Songfilelist[i] = Songfilelist[i] + "}";
                            }
                            else
                            {
                                if (i == Songfilelist.Length - 1 && i != 0)
                                {
                                    Songfilelist[i] = "{" + Songfilelist[i];
                                }
                            }
                        }
                        JObject songdinfo = JObject.Parse(Songfilelist[i]);
                        if (songdinfo["format"].ToString() == "flac")
                        {
                            return(@"http://zhangmenshiting.baidu.com/data2/music/" + songdinfo["file_id"] + @"/" + songdinfo["file_id"] + @".flac");
                        }
                        else
                        {
                            return(@"http://zhangmenshiting.baidu.com/data2/music/" + songdinfo["file_id"] + @"/" + songdinfo["file_id"] + @".mp3");
                        }
                    }
                    return("");
                }
                catch (Exception ex)
                {
                    return("");
                }
            }
Beispiel #10
0
        public void checkproxy()
        {
            ProxyIP pp = new ProxyIP();

            pp.IP    = "101.71.27.120";
            pp.Port  = "80";
            pp.Place = "未知";
            if (pp != null)
            {
                HttpWebRequest Req;
                WebProxy       proxyObject = new WebProxy(pp.IP, Convert.ToInt32(pp.Port)); // port为端口号 整数型
                Req         = WebRequest.Create("http://www.google.com/") as HttpWebRequest;
                Req.Proxy   = proxyObject;                                                  //设置代理
                Req.Timeout = mySetting.timeout;                                            //超时
                DateTime dt1 = DateTime.Now;
                try
                {
                    if (pp.Place == "未知")
                    {
                        HttpHelper http = new HttpHelper();
                        HttpItem   item = new HttpItem();
                        item.URL = "http://www.ip.cn/index.php?ip=" + pp.IP;
                        HttpResult result   = http.GetHtml(item);
                        string     strPlace = result.Html;
                        if (!string.IsNullOrEmpty(strPlace))
                        {
                            strPlace = Search_string(strPlace, "来自:", "</p><p>");
                            pp.Place = strPlace;
                            //AddProxyIP(pp);
                        }
                    }
                }
                catch { }//忽略错误
                try
                {
                    HttpWebResponse Resp = (HttpWebResponse)Req.GetResponse();
                    DateTime        dt2  = DateTime.Now;
                    Encoding        bin  = Encoding.GetEncoding("utf-8");
                    StreamReader    sr   = new StreamReader(Resp.GetResponseStream(), bin);
                    string          str  = sr.ReadToEnd();
                    sr.Close();
                    sr.Dispose();
                    if (str.Contains("百度"))
                    {
                        //result = true;
                        TimeSpan ts = dt2 - dt1;
                        pp.Speed = ((long)ts.TotalMilliseconds).ToString();
                        //AddProxyIP(pp);
                    }
                }
                catch (Exception ex)
                {
                    pp.Speed = "超时";
                    AddProxyIP(pp);
                    Trace.WriteLine(ex.Message);
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// 验证list集合里面的代理IP
        /// </summary>
        /// <param name="msg"></param>
        public static void ProxyVerification(object msg, string name)
        {
            if (null == msg)
            {
                return;
            }
            ProxyViewModel proxy = (ProxyViewModel)msg;

            try
            {
                using (WebClient web = new WebClient())
                {
                    try
                    {
                        HttpWebRequest  Req;
                        HttpWebResponse Resp;
                        WebProxy        proxyObject = new WebProxy(proxy.ProxyIP, proxy.ProxyPort);
                        Req         = WebRequest.Create("https://www.baidu.com") as HttpWebRequest;
                        Req.Proxy   = proxyObject; //设置代理
                        Req.Timeout = 3000;        //超时
                        Resp        = (HttpWebResponse)Req.GetResponse();
                        Encoding bin = Encoding.GetEncoding("UTF-8");
                        using (StreamReader sr = new StreamReader(Resp.GetResponseStream(), bin))
                        {
                            string str = sr.ReadToEnd();
                            if (str.Contains("百度"))
                            {
                                Resp.Close();
                                // 更新验证时间
                                proxy.CreateTime = DateTime.Now;
                                // 更新验证状态
                                proxy.State = 1;
                                // 验证通过,归队
                                QueueOperation(proxy, IQueueType.EnQueue);
                                Console.WriteLine("{0}> [{2}]自动验证成功{1}", DateTime.Now.ToString("s"), proxy.Id, name);
                            }
                            else
                            {
                                Console.WriteLine("{0}> [{2}]自动验证失败{1}", DateTime.Now.ToString("s"), proxy.Id, name);
                            }
                        }
                    }
                    catch (Exception ex)
                    { }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("{0}> [{3}]自动验证异常{1} {2}", DateTime.Now.ToString("s"), proxy.Id, e.Message, name);
            }
        }
Beispiel #12
0
        /// <summary>
        /// 通过代理ip访问地址
        /// </summary>
        /// <param name="url">要访问的地址</param>
        /// <param name="html">返回的html</param>
        static void getHtmlstr(string url, ref string html)
        {
            Console.WriteLine("当前代理ip数量" + _ProxyQueue.Where(model => model.State == 1).Count());
            var proxy = _ProxyQueue.FirstOrDefault(model => model.State == 1);//从代理iplist中取一个

            if (proxy == null)
            {
                XiciGaoni();
                getHtmlstr(url, ref html);
            }
            else
            {
                try
                {
                    Console.WriteLine("开始使用" + proxy.ProxyIP + ":" + proxy.ProxyPort + "访问 : " + url);
                    HttpWebRequest  Req;
                    HttpWebResponse Resp;
                    WebProxy        proxyObject = new WebProxy(proxy.ProxyIP, proxy.ProxyPort); // port为端口号 整数型
                    Req           = WebRequest.Create(url) as HttpWebRequest;
                    Req.Proxy     = proxyObject;                                                //设置代理
                    Req.Timeout   = 2000;                                                       //超时
                    Req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36";
                    Resp          = (HttpWebResponse)Req.GetResponse();
                    Encoding bin = Encoding.GetEncoding("UTF-8");
                    using (StreamReader sr = new StreamReader(Resp.GetResponseStream(), bin))
                    {
                        string str = sr.ReadToEnd();
                        if (str.Contains("异常"))
                        {
                            Resp.Close();
                            // 更新验证状态
                            proxy.State = 0;
                            getHtmlstr(url, ref html);
                        }
                        else
                        {
                            Console.WriteLine("访问成功!");
                            html = str;
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("使用" + proxy.ProxyIP + ":" + proxy.ProxyPort + " 发生 " + e.Message);
                    proxy.State = 0;
                    getHtmlstr(url, ref html);
                }
            }
        }
Beispiel #13
0
            /// <summary>
            /// 搜索函数
            /// </summary>
            /// <param name="Query">必选,关键字</param>
            /// <param name="PageNumber">可选,页码,默认为1</param>
            /// <param name="PageSize">可选,每页数据条数,默认为20</param>
            /// <returns>结果</returns>
            public static ResultData Search(string Query, int PageNumber = 1, int PageSize = 20)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    Req = (HttpWebRequest)WebRequest.Create(@"http://songsearch.kugou.com/song_search_v2?clientver=8018&keyword=" + HttpUtility.UrlEncode(Query, Encoding.UTF8) + @"&pagesize=" + PageSize + @"&page=" + PageNumber);
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    JObject      p      = JObject.Parse(str);
                    ResultData   Result = new ResultData {
                        List1 = new List <SongListItem>()
                    };
                    Result.Tot = int.Parse(p["data"]["total"].ToString());
                    foreach (var songinfo in p["data"]["lists"])
                    {
                        SongListItem SLI = new SongListItem {
                            Album1 = songinfo["AlbumName"].ToString(), Singer1 = songinfo["SingerName"].ToString(), SongId1 = songinfo["ID"].ToString(), SongName1 = songinfo["SongName"].ToString(), Lrc1 = "", Quality1 = new QualityList(), Pic1 = new SongPic(), SongInterval1 = songinfo["Duration"].ToString()
                        };
                        SLI.Lrc1 = "http://lyrics.kugou.com/search?ver=1&man=yes&client=pc&keyword=" + HttpUtility.UrlEncode(songinfo["SingerName"].ToString() + "-" + songinfo["SongName"].ToString(), Encoding.UTF8) + "&duration=" + songinfo["Duration"].ToString() + "000&hash=" + songinfo["FileHash"].ToString();
                        if (songinfo["FileHash"].ToString() != "00000000000000000000000000000000")
                        {
                            SLI.Quality1.Q128 = true;
                            SLI.Quality1.S128 = songinfo["FileSize"].ToString();
                            SLI.Quality1.F128 = songinfo["FileHash"].ToString();
                        }
                        if (songinfo["HQFileHash"].ToString() != "00000000000000000000000000000000")
                        {
                            SLI.Quality1.Q320 = true;
                            SLI.Quality1.S320 = songinfo["HQFileSize"].ToString();
                            SLI.Quality1.F320 = songinfo["HQFileHash"].ToString();
                        }
                        if (songinfo["SQFileHash"].ToString() != "00000000000000000000000000000000")
                        {
                            SLI.Quality1.Ape  = true;
                            SLI.Quality1.Sape = songinfo["SQFileSize"].ToString();
                            SLI.Quality1.Fape = songinfo["SQFileHash"].ToString();
                        }
                        Result.List1.Add(SLI);
                    }
                    return(Result);
                }
                catch (Exception ex)
                {
                    return(new ResultData());
                }
            }
Beispiel #14
0
            /// <summary>
            /// 获取xcode值
            /// </summary>
            /// <param name="SongId">必选,歌曲ID</param>
            /// <returns>xcode值</returns>
            public static string GetXcode(string SongId)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    Req = (HttpWebRequest)WebRequest.Create(@"http://music.baidu.com/data/music/links?songIds=" + SongId);
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    JObject      p      = JObject.Parse(str);
                    return(Regex.Split(Regex.Split(p["data"].First.ToString(), ":")[1], "\"")[1]);
                }
                catch (Exception ex)
                {
                    return("");
                }
            }
Beispiel #15
0
            /// <summary>
            /// 获取文件参数
            /// </summary>
            /// <returns>vkey等,直接接在链接后即可</returns>
            public static string GetVkey()
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    Req = (HttpWebRequest)WebRequest.Create(@"https://c.y.qq.com/base/fcgi-bin/fcg_musicexpress.fcg?json=3&guid=4450729731&g_tk=938407465&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=GB2312&notice=0&platform=yqq&needNewCode=0");
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    JObject      p      = JObject.Parse(str);
                    return("?vkey=" + p["key"] + "&guid=4450729731&fromtag=30");
                }
                catch (Exception ex)
                {
                    return("");
                }
            }
Beispiel #16
0
            /// <summary>
            /// 获取歌曲下载信息
            /// </summary>
            /// <param name="Hash">必选,歌曲Hash</param>
            /// <returns>歌曲地址</returns>
            public static string GetSongUrl(string Hash)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    Req = (HttpWebRequest)WebRequest.Create(@"http://trackercdn.kugou.com/i/?cmd=4&hash=" + Hash + @"&key=" + GetMd5HashStr(Hash + "kgcloud") + "&pid=1");
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    System.Diagnostics.Debug.WriteLine(str);
                    JObject p = JObject.Parse(str);
                    return(p["url"].ToString());
                }
                catch (Exception ex)
                {
                    return("");
                }
            }
Beispiel #17
0
            ///<summary>
            /// 获取地址
            /// </summary>
            /// <param name="LinkStr">连接字符串,储存在fother</param>
            /// <returns>歌曲地址</returns>
            public static string GetSong(string LinkStr)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    Req = (HttpWebRequest)WebRequest.Create(@"http://5sing.kugou.com/m/detail/" + LinkStr + "-1.html");
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    str = Regex.Split(str, "<audio src=\"")[1];
                    str = Regex.Split(str, "\" id=\"player\" volume=\"0.5\"></audio>")[0];
                    return(str);
                }
                catch (Exception ex)
                {
                    return("");
                }
            }
Beispiel #18
0
        /// <summary>
        /// 验证将要从接口出去的代理IP
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static bool DbVerIp(ProxyViewModel proxy)
        {
            bool      success = false;
            Stopwatch sw      = new Stopwatch();

            sw.Start();
            try
            {
                HttpWebRequest  Req;
                HttpWebResponse Resp;
                WebProxy        proxyObject = new WebProxy(proxy.ProxyIP, proxy.ProxyPort); // port为端口号 整数型
                Req         = WebRequest.Create("https://www.baidu.com") as HttpWebRequest;
                Req.Proxy   = proxyObject;                                                  //设置代理
                Req.Timeout = 3000;                                                         //超时
                Resp        = (HttpWebResponse)Req.GetResponse();
                Encoding bin = Encoding.GetEncoding("UTF-8");
                using (StreamReader sr = new StreamReader(Resp.GetResponseStream(), bin))
                {
                    string str = sr.ReadToEnd();
                    if (str.Contains("百度"))
                    {
                        Resp.Close();
                        // 更新验证时间
                        proxy.CreateTime = DateTime.Now;
                        // 更新验证状态
                        proxy.State = 1;
                        // 记录验证状态
                        success = true;
                        // 验证通过,归队
                        QueueOperation(proxy, IQueueType.EnQueue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("{0}> 接口验证异常{1}", DateTime.Now.ToString("s"), e.Message);
            }
            sw.Stop();
            Console.WriteLine("{0}> 接口验证{1} {2} 耗时{3}s", DateTime.Now.ToString("s"), proxy.Id, success, sw.ElapsedMilliseconds / 1000.00);
            return(success);
        }
Beispiel #19
0
            /// <summary>
            /// 搜索函数
            /// </summary>
            /// <param name="Query">必选,关键字</param>
            /// <param name="PageNumber">可选,页码,默认为1</param>
            /// <param name="PageSize">可选,每页数据条数,默认为20</param>
            /// <returns>结果</returns>
            public static ResultData Search(string Query, int PageNumber = 1, int PageSize = 20)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    Req = (HttpWebRequest)WebRequest.Create("http://tingapi.ting.baidu.com/v1/restserver/ting?from=webqpp_music&format=json&callback=&method=baidu.ting.search.common&query=" + HttpUtility.UrlEncode(Query, Encoding.UTF8) + @"&page_size=" + PageSize + @"&page_no=" + PageNumber);
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    str = str.Replace("<em>", "").Replace(@"<\/em>", "");
                    JObject    p          = JObject.Parse(str);
                    string[]   Songlist   = Regex.Split(p["song_list"].ToString().Replace("[", "").Replace("]", "").Replace("\r\n", "").Replace(" ", ""), "},{");
                    JObject    SearchInfo = JObject.Parse(p["pages"].ToString());
                    ResultData Result     = new ResultData {
                        List1 = new List <SongListItem>()
                    };
                    Result.Tot = int.Parse(SearchInfo["total"].ToString());
                    for (int i = 0; i < Songlist.Length; i++)
                    {
                        if (i != 0 && i != Songlist.Length - 1)
                        {
                            Songlist[i] = "{" + Songlist[i] + "}";
                        }
                        else
                        {
                            if (i == 0 && i != Songlist.Length - 1)
                            {
                                Songlist[i] = Songlist[i] + "}";
                            }
                            else
                            {
                                if (i == Songlist.Length - 1 && i != 0)
                                {
                                    Songlist[i] = "{" + Songlist[i];
                                }
                            }
                        }
                        JObject      songinfo = JObject.Parse(Songlist[i]);
                        SongListItem SLI      = new SongListItem {
                            Album1 = songinfo["album_title"].ToString(), Singer1 = songinfo["author"].ToString(), SongId1 = songinfo["song_id"].ToString(), SongName1 = songinfo["title"].ToString(), Lrc1 = songinfo["lrclink"].ToString(), Quality1 = new QualityList(), Pic1 = new SongPic(), SongInterval1 = ""
                        };
                        string[] rate = songinfo["all_rate"].ToString().Split(',');
                        for (int j = 0; j < rate.Length; j++)
                        {
                            switch (rate[j])
                            {
                            case "128":
                                SLI.Quality1.Q128 = true;
                                break;

                            case "192":
                                SLI.Quality1.Q192 = true;
                                break;

                            case "256":
                                SLI.Quality1.Q256 = true;
                                break;

                            case "320":
                                SLI.Quality1.Q320 = true;
                                break;

                            case "flac":
                                SLI.Quality1.Flac = true;
                                break;

                            case "ape":
                                SLI.Quality1.Ape = true;
                                break;
                            }
                        }
                        Result.List1.Add(SLI);
                    }
                    return(Result);
                }
                catch (Exception ex)
                {
                    return(new ResultData());
                }
            }
Beispiel #20
0
            /// <summary>
            /// 获取歌曲文件
            /// </summary>
            /// <param name="Result">必选,搜索结果</param>
            /// <returns>结果</returns>
            public static SongListItem GetSong(SongListItem Result)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    byte[] param = Encoding.UTF8.GetBytes("param=" + Convert.ToBase64String(Encoding.UTF8.GetBytes("{\"key\":\"" + Result.SongId1 + "\",\"rate\":\"128,192,256,320,flac\",\"linkType\":0,\"isCloud\":0,\"version\":\"10.1.8.3\"}")));
                    Req             = (HttpWebRequest)WebRequest.Create(@"http://musicmini2014.baidu.com/2016/app/link/getLinks.php");
                    Req.Method      = "POST";
                    Req.ContentType = "application/x-www-form-urlencoded";
                    Req.UserAgent   = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.2; WOW64; Trident/7.0)";
                    Stream reqstream = Req.GetRequestStream();
                    reqstream.Write(param, 0, param.Length);
                    reqstream.Close();
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    JObject      p      = JObject.Parse(str);
                    Result.Lrc1         = p["lyric_url"].ToString();
                    Result.Pic1.Large1  = p["album_image_url"].ToString();
                    Result.Pic1.Middle1 = Regex.Split(p["album_image_url"].ToString(), ",")[0] + ",w_250";
                    Result.Pic1.Small1  = p["small_album_image_url"].ToString();
                    string[] Songfilelist = Regex.Split(p["file_list"].ToString().Replace("[", "").Replace("]", "").Replace("\r\n", "").Replace(" ", ""), "},{");
                    for (int i = 0; i < Songfilelist.Length; i++)
                    {
                        if (i != 0 && i != Songfilelist.Length - 1)
                        {
                            Songfilelist[i] = "{" + Songfilelist[i] + "}";
                        }
                        else
                        {
                            if (i == 0 && i != Songfilelist.Length - 1)
                            {
                                Songfilelist[i] = Songfilelist[i] + "}";
                            }
                            else
                            {
                                if (i == Songfilelist.Length - 1 && i != 0)
                                {
                                    Songfilelist[i] = "{" + Songfilelist[i];
                                }
                            }
                        }
                        JObject songdinfo = JObject.Parse(Songfilelist[i]);
                        if (int.Parse(songdinfo["kbps"].ToString()) <= 320)
                        {
                            switch (int.Parse(songdinfo["kbps"].ToString()))
                            {
                            case 128:
                                Result.Quality1.F128 = @"http://zhangmenshiting.baidu.com/data2/music/" + songdinfo["file_id"] + @"/" + songdinfo["file_id"] + @".mp3";
                                Result.Quality1.S128 = songdinfo["size"].ToString();
                                break;

                            case 192:
                                Result.Quality1.F192 = @"http://zhangmenshiting.baidu.com/data2/music/" + songdinfo["file_id"] + @"/" + songdinfo["file_id"] + @".mp3";
                                Result.Quality1.S192 = songdinfo["size"].ToString();
                                break;

                            case 256:
                                Result.Quality1.F256 = @"http://zhangmenshiting.baidu.com/data2/music/" + songdinfo["file_id"] + @"/" + songdinfo["file_id"] + @".mp3";
                                Result.Quality1.S256 = songdinfo["size"].ToString();
                                break;

                            case 320:
                                Result.Quality1.F320 = @"http://zhangmenshiting.baidu.com/data2/music/" + songdinfo["file_id"] + @"/" + songdinfo["file_id"] + @".mp3";
                                Result.Quality1.S320 = songdinfo["size"].ToString();
                                break;
                            }
                        }
                        else
                        {
                            Result.Quality1.Fflac = @"http://zhangmenshiting.baidu.com/data2/music/" + songdinfo["file_id"] + @"/" + songdinfo["file_id"] + @".flac";
                            Result.Quality1.Sflac = songdinfo["size"].ToString();
                        }
                    }
                    return(Result);
                }
                catch (Exception ex)
                {
                    return(Result);
                }
            }
Beispiel #21
0
            /// <summary>
            /// 搜索函数
            /// </summary>
            /// <param name="Query">必选,关键字</param>
            /// <param name="PageNumber">可选,页码,默认为1</param>
            /// <param name="PageSize">可选,每页数据条数,默认为20</param>
            /// <returns>结果</returns>
            public static ResultData Search(string Query, int PageNumber = 1, int PageSize = 20)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    Req = (HttpWebRequest)WebRequest.Create(@"http://c.y.qq.com/soso/fcgi-bin/search_cp?remoteplace=txt.yqq.center&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=" + PageNumber + "&n=" + PageSize + "&w=" + HttpUtility.UrlEncode(Query, Encoding.UTF8) + @"&format=json&inCharset=utf8&outCharset=utf-8&platform=yqq");
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    JObject      p      = JObject.Parse(str);
                    ResultData   Result = new ResultData {
                        List1 = new List <SongListItem>()
                    };
                    Result.Tot = int.Parse(p["data"]["song"]["totalnum"].ToString());
                    foreach (var songinfo in p["data"]["song"]["list"])
                    {
                        SongListItem SLI = new SongListItem {
                            Album1 = songinfo["albumname"].ToString(), Singer1 = "", SongId1 = songinfo["songmid"].ToString(), SongName1 = songinfo["songname"].ToString(), Lrc1 = "", Quality1 = new QualityList(), Pic1 = new SongPic(), SongInterval1 = songinfo["interval"].ToString()
                        };
                        SLI.Pic1.Large1  = "https://y.gtimg.cn/music/photo_new/T002R800x800M000" + songinfo["albummid"].ToString() + ".jpg?max_age=2592000";
                        SLI.Pic1.Middle1 = "https://y.gtimg.cn/music/photo_new/T002R500x500M000" + songinfo["albummid"].ToString() + ".jpg?max_age=2592000";
                        SLI.Pic1.Small1  = "https://y.gtimg.cn/music/photo_new/T002R200x200M000" + songinfo["albummid"].ToString() + ".jpg?max_age=2592000";
                        SLI.Lrc1         = "https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?format=json&platform=yqq&g_tk=938407465&songmid=" + songinfo["songmid"].ToString();
                        if (int.Parse(songinfo["type"].ToString()) == 0)
                        {
                            if (int.Parse(songinfo["size128"].ToString()) != 0)
                            {
                                SLI.Quality1.Q128 = true;
                                SLI.Quality1.S128 = songinfo["size128"].ToString();
                                SLI.Quality1.F128 = "http://dl.stream.qqmusic.qq.com/M500" + songinfo["songmid"].ToString() + ".mp3";
                            }
                            if (int.Parse(songinfo["size320"].ToString()) != 0)
                            {
                                SLI.Quality1.Q320 = true;
                                SLI.Quality1.S320 = songinfo["size320"].ToString();
                                SLI.Quality1.F320 = "http://dl.stream.qqmusic.qq.com/M800" + songinfo["songmid"].ToString() + ".mp3";
                            }

                            //接口不支持获取无损歌曲
                            //if (int.Parse(songinfo["sizeape"].ToString()) != 0)
                            //{
                            //    SLI.Quality1.Ape = true;
                            //    SLI.Quality1.Sape = songinfo["sizeape"].ToString();
                            //    SLI.Quality1.Fape = "http://dl.stream.qqmusic.qq.com/A000" + songinfo["songmid"].ToString() + ".ape";
                            //}
                            //if (int.Parse(songinfo["sizeflac"].ToString()) != 0)
                            //{
                            //    SLI.Quality1.Flac = true;
                            //    SLI.Quality1.Sflac = songinfo["sizeflac"].ToString();
                            //    SLI.Quality1.Fflac = "http://dl.stream.qqmusic.qq.com/F000" + songinfo["songmid"].ToString() + ".flac";
                            //}
                        }
                        else
                        {
                            if (int.Parse(songinfo["type"].ToString()) == 2)
                            {
                                SLI.Quality1.Qother = true;
                                SLI.Quality1.Fother = songinfo["songurl"].ToString();
                            }
                        }
                        SLI.Singer1 = songinfo["singer"][0]["name"].ToString();
                        Result.List1.Add(SLI);
                    }
                    return(Result);
                }
                catch (Exception ex)
                {
                    return(new ResultData());
                }
            }