Exemplo n.º 1
0
        private static void saveSong(string songLink)
        {
            HtmlWeb web = new HtmlWeb();

            HtmlDocument doc = web.Load(songLink);
            var songTitleList = doc.DocumentNode.SelectNodes("//div[@class=\"songbody\"]/p")[0].InnerText;
            //Console.WriteLine(songLink);
            string songTitle = doc.DocumentNode.SelectNodes("//div[@class=\"latest\"]/h1")[0].InnerText;
            string songLyrics = songTitleList;
            if (songLyrics.Length > 0 && songTitle.Length > 0)
            {
                string replacedTitle = "";
                Song s;
                if (songTitle.Contains("-"))
                {
                    replacedTitle = songTitle.Replace("\\-", "_");
                    replacedTitle = replacedTitle.Replace('#', '_');
                    s = new Song(replacedTitle, songLyrics);
                }
                else
                {
                    s = new Song(songTitle, songLyrics);
                }

                writeSongToFile(s);
            }
        }
Exemplo n.º 2
0
 private static void writeSongToFile(Song s)
 {
     try
     {
         using (StreamWriter outfile = new StreamWriter(@"D:\Development\MusicLyricsDataScrapper\output_lyrics\" + s.getLetter() + "_" + s.getTitle()))
         {
             outfile.Write(s.getLyrics());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("found exception with : " + s.getLetter() + "+" + s.getTitle());
     }
 }