private void FetchData() { var uri = new Uri("https://tureng.com/tr/turkce-ingilizce/"); var content = ""; var inputText = searchBox.Text; var meaning = ""; try { var html = ""; var css = ""; HtmlNode node; switch (_dictionary) { case WebDictionary.Tureng: uri = new Uri("https://tureng.com/tr/turkce-ingilizce/" + inputText); var turengBot = new Bot(uri, new WebClient()); node = turengBot.SelectNode("//*[@id='englishResultsTable']"); html = node.OuterHtml.Replace("href=", ""); meaning = turengBot.SelectNode("//*[@id='englishResultsTable']/tr[4]/td[4]/a").InnerHtml; css = "\n<style type=\"text/css\">\n" + Properties.Resources.css + "\n</style> "; content = html + css; break; case WebDictionary.MerriamWebster: uri = new Uri("https://www.merriam-webster.com/dictionary/" + inputText); var merriamBot = new Bot(uri, new WebClient()); merriamBot.ClearDocument("//div[@class='anchor-list']", "//div[@id='synonyms-anchor']", "//a[@class='widget-button thesaurus hoverable']", "//span[@id='in-sentences']", "//span[@id='on-web']", "//div[@class='on-web']", "//div[@class='widget learn_more']", "//div[@class='widget more-from']", "//div[@class='widget seen-and-heard-block']"); node = merriamBot.SelectNode("//div[@id='left-content']"); html = node.OuterHtml.Replace("href=", ""); css = "\n<style type=\"text/css\">\n" + Properties.Resources.merriamcss + "\n</style> "; content = html + css; break; case WebDictionary.Cambridge: //cambridge bot uri = new Uri("https://dictionary.cambridge.org/tr/sözlük/ingilizce-türkçe/" + inputText); var cambridgeBot = new Bot(uri, new WebClient()); cambridgeBot.ClearDocument("//div[@class='share rounded js-share']", "//h3[@class='h4 txt-block txt-block--alt']", "//div[@class='xref see_also margin-bottom']", "//div[@class='item']"); node = cambridgeBot.SelectNode( "//div[@class='di $ entry-body__el entry-body__el--smalltop clrd js-share-holder']"); html = node.OuterHtml.Replace("href=", ""); css = "\n<style type=\"text/css\">\n" + Properties.Resources.cambridgecss + "\n</style> "; content = html + css; break; } JsonOperator fileOperator; if (chromWebBrowser.InvokeRequired) { chromWebBrowser.Invoke((MethodInvoker) delegate { chromWebBrowser.LoadHtml(css + html, uri.AbsoluteUri); fileOperator = new JsonOperator(FilePaths.TemporaryFiles.LastPage); fileOperator.SaveToFile(content); }); } meaning = WebUtility.HtmlDecode(meaning); fileOperator = new JsonOperator(FilePaths.TemporaryFiles.LastWord); fileOperator.SaveToFile(inputText + "/" + meaning); } catch (WebException exception) { content = Properties.Resources.errorpage; content = content.Replace("info", "Internet yok yada baglanti kurulamadi"); content = content.Replace("inserterrormessagehere", uri.AbsoluteUri + "bulunamadi"); content = content.Replace("insertexceptionhere", exception.ToString()); if (chromWebBrowser.InvokeRequired) { chromWebBrowser.Invoke((MethodInvoker) delegate { chromWebBrowser.LoadHtml(content); }); } else { chromWebBrowser.LoadHtml(content); } } catch (NullReferenceException exception) { content = Properties.Resources.errorpage; content = content.Replace("info", "Aradidigin Kelimeyi Bulamadim"); content = content.Replace("inserterrormessagehere", "Loglar " + FilePaths.PermanentFiles.Logs + " 'a kaydedildi."); content = content.Replace("insertexceptionhere", "Bir Seferlik Arama Butonuna Basarak Ara"); LogOperator.Log(exception); if (chromWebBrowser.InvokeRequired) { chromWebBrowser.Invoke((MethodInvoker) delegate { chromWebBrowser.LoadHtml(content); }); } else { chromWebBrowser.LoadHtml(content); } } }