示例#1
0
        public static async Task MainAsync(String url = "")
        {
            url = String.IsNullOrEmpty(url)?Console.ReadLine():url;
            BitcoinTalkTopicScrapper BtcTalkParser = new BitcoinTalkTopicScrapper();
            BitcoinTalkPage          page          = await BtcTalkParser.ScrappeTopic(url);

            ExportToJSON(page);
            Console.WriteLine("Export completed!");
            Console.ReadLine();
        }
示例#2
0
 private static void ExportToJSON(BitcoinTalkPage btcPage, String fileName = "")
 {
     try
     {
         string rawJson = JsonConvert.SerializeObject(btcPage, Formatting.Indented);
         if (!String.IsNullOrEmpty(fileName) && File.Exists(fileName) && fileName.ToLower().EndsWith(".json"))
         {
             File.WriteAllText(fileName, rawJson);
         }
         else
         {
             fileName = AppDomain.CurrentDomain.BaseDirectory + "\\export_" + DateTime.Now.ToString("ddMMMyyyy_hhmmss") + ".json";
             File.WriteAllText(fileName, rawJson);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("\nUnable to write json export file, {0}!\n", fileName);
     }
 }