static void Main(string[] args) { //Buddy.TorrentSearcher searcher = new Buddy.TorrentSearcher(); //searcher.InfoReady += UpdateInfoFromTorrentSearcher; //searcher.Search("http://kat.ph/usearch/arrow", "magnet:\\?.+"); Conrad_Lib.WebPage webpage = new Conrad_Lib.WebPage(); //webpage.Load("https://www.google.com"); //Console.WriteLine(webpage.htmlData); //Console.Read(); //bool exit = false; //while (exit == false) //{ // string input = Console.ReadLine(); // if (input == "q") // { // break; // } // input = "https://www.google.com.sg/?gfe_rd=cr&ei=y5RVVtD9M5uGuwSozIWADw&gws_rd=ssl#q=abc" + "\"" + input + "\""; // webpage.Load(input); // Console.WriteLine(webpage.htmlData); //} using (WebClient client = new WebClient()) // WebClient class inherits IDisposable { //client.DownloadFile("http://ultimate-guitar.com", "C:\\Users\\Conrad\\Downloads"); // Or you can get the file content without saving it: string htmlCode = client.DownloadString("https://kat.cr/usearch/arrow/"); Conrad_Lib.File myFile = new Conrad_Lib.File(@"C:\Users\Conrad\Downloads\temp.txt"); myFile.SetFileContent(htmlCode); myFile.Save(); //... Console.WriteLine(htmlCode); Console.Read(); } }
private void WebBrowser_Main_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { WebBrowser webpage = (WebBrowser)sender; string htmlData = webpage.Document.ActiveElement.InnerHtml; Conrad_Lib.File file = new Conrad_Lib.File(); System.IO.Directory.CreateDirectory(System.IO.Directory.GetCurrentDirectory() + @"\WebData"); file.SetRelativeSubDirectory(@"WebData"); file.SetFileName(@"webdata.txt"); //file.SetFilePath(@"C:\Users\Conrad\Downloads\temp.txt"); if(htmlData != null) { file.SetFileContent(htmlData); file.Save(); //List<string> matches = Conrad_Lib.StaticFunctions.RegexMatch(htmlData, "magnet:\\?[^\"]+"); currentHtmlData = htmlData; TextBox_AddressBar.Text = webpage.Url.ToString(); if (webPageQueue.Count() > 0) { string nextURL = webPageQueue.First(); webPageQueue.RemoveAt(0); webpage.Navigate(nextURL); } else { //string msg = "[" + DateTime.Now.ToString("dd/MM/yy") + "] " + "Scan completed at " + DateTime.Now.ToString("h:mm:ss tt"); //SendToMainDisplay(msg); // Log(msg); } //webpage.Navigate(@"https://www.google.com"); } BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += ScanForNewEpisodesInBackground; worker.RunWorkerAsync(); }
void Initialize() { //Object Creation parser = new Parser(); torrentData = new Buddy.Objects.Torrent.TorrentData(); webPageQueue = new List<string>(); timer = new System.Timers.Timer(1000 * updateFrequencyinSeconds); logFile = new Conrad_Lib.File(); //Event assignment torrentData.NeedsDataToUpdate += PerformSearch; torrentData.NewEpisodeFound += NewEpisodeFoundHandler; torrentData.SeriesCompletedScan += SeriesCompletedScanHandler; Load += HideWindow; timer.Elapsed += TimeElapsed; //Display Updates Display_EpisodeData.Text = torrentData.EpisodeData(); trayIcon = new NotifyIcon(); trayIcon.Icon = new Icon(@"Z:\Program Files\Visual Prolog 7.5\icons\categories\applications-system.ico"); trayIcon.Text = "Buddy\nNo new notifications"; trayIcon.Visible = true; trayIcon.MouseDoubleClick += ShowWindow; ContextMenu trayIconContextMenu = new ContextMenu(); MenuItem menu_exit = new MenuItem(); menu_exit.Text = "Exit"; menu_exit.Index = 0; menu_exit.Click += ExitForm; trayIconContextMenu.MenuItems.Add(menu_exit); trayIcon.ContextMenu = trayIconContextMenu; //Timer timer.AutoReset = true; timer.Start(); BackgroundWorker bg = new BackgroundWorker(); bg.DoWork += UpdateTimerDisplay; bg.RunWorkerAsync(); //Log File logFile.SetDirectory(System.Environment.CurrentDirectory); logFile.SetFileName(FILENAME_LOGFILE); logFile.Load(); }