示例#1
0
        void tet1()
        {
            // 得到 词作者,曲作者, txt歌词
            //http://www.xiami.com/song/1771445580
            string      xm_songid   = "1771445580";
            LrcSongInfo lrcSongInfo = ClawLyricAction(xm_songid);

            Console.WriteLine(lrcSongInfo.Lyricist);
            Console.WriteLine(lrcSongInfo.Composer);

            Console.WriteLine(lrcSongInfo.LrcText);
            Console.WriteLine("完毕");
        }
示例#2
0
        public int UpdateXM_CN_EN_56876Service(LrcSongInfo lyricInfo)
        {
            int result = 0;

            try
            {
                SqlParameter[] parms = new SqlParameter[] {
                    new SqlParameter("xm_songid", lyricInfo.XM_SongId),
                    new SqlParameter("lyricist", lyricInfo.Lyricist),
                    new SqlParameter("composer", lyricInfo.Composer),
                    new SqlParameter("lrctxt", lyricInfo.LrcText),
                    new SqlParameter("lyric", lyricInfo.Lyric)
                };

                result = HelperSQL.ExecNonQuery("usp_XM_Spider_updateLrcBySongId", parms, System.Data.CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                LogNet.LogBLL.Error("UpdateXM_CN_EN_56876Service", ex);
            }

            return(result);
        }
示例#3
0
        public LrcSongInfo ClawLyricAction(string xm_songid)
        {
            Thread.Sleep(5000);
            LrcSongInfo lyricSong = new LrcSongInfo();

            lyricSong.XM_SongId = xm_songid;
            string url = "http://www.xiami.com/song/" + xm_songid;

            try
            {
                string html = HttpHelper.Open(url, encoding);

                // lyricSong.SongName = CommonHelper.NoHTML(CommonHelper.GetMatchRegex(SongNameRegex, html));
                //  lyricSong.BelongAlbum = CommonHelper.NoHTML(CommonHelper.GetMatchRegex(BelongAlbumRegex, html));
                //  lyricSong.Singer = CommonHelper.NoHTML(CommonHelper.GetMatchRegex(SingerRegex, html));
                lyricSong.Lyricist = CommonHelper.NoHTML(CommonHelper.GetMatchRegex(LyricistRegex, html));
                lyricSong.Composer = CommonHelper.NoHTML(CommonHelper.GetMatchRegex(ComposerRegex, html));
                lyricSong.LrcText  = CommonHelper.GetMatchRegex(LrcTxtRegx, html);
                lyricSong.LrcText  = Regex.Replace(lyricSong.LrcText, "<.+?>", "").Replace("				", "").Replace(" 歌词:", "").Replace("                ", "");

                // lyricSong.AlbumUrl = "http://www.xiami.com" + CommonHelper.GetMatchRegex(BelongAlbumUrlRegex, html);
                // lyricSong.ArtistUrl = "http://www.xiami.com" + CommonHelper.GetMatchRegex(ArtistUrlRegex, html);
                // lyricSong.ArtistImgUrl = CommonHelper.GetMatchRegex(SingerImgRegex, html);
                // lyricSong.AlbumImgUrl = CommonHelper.GetMatchRegex(AlbumImgRegex, html);

                lyricSong.Lyric = GetLyricBySongIdAction(xm_songid);
            }
            catch (Exception ex)
            {
                lyricSong.Lyricist = "";
                lyricSong.Composer = "";
                lyricSong.LrcText  = "";
                lyricSong.Lyric    = "";
                LogBLL.Error("ClawLyricAction", ex);
            }
            return(lyricSong);
        }
示例#4
0
        public void MianWork()
        {
            List <string> list = serviceDal.GetTaskSongIdList();

            int i = 0;

            foreach (string xm_songId in list)
            {
                i++;
                Console.WriteLine("当前任务进度\t{0}/{1}", i, list.Count);
                LrcSongInfo lrcSongInfo = ClawLyricAction(xm_songId);
                //更新数据

                int result = serviceDal.UpdateXM_CN_EN_56876Service(lrcSongInfo);
                if (result > 0)
                {
                    Console.WriteLine("\t更新成功!");
                }
                else
                {
                    Console.WriteLine("\t更新失败!");
                }
            }
        }