//bool match(string s1, string s2) //{ //} bool compare_result(string title) { string s1_org = selenium1.GetHtmlSource(); string s2_org = selenium2.GetHtmlSource(); Regex reg = new Regex("<span class=\"changing\">.*</span>", RegexOptions.IgnoreCase); string s1 = reg.Replace(s1_org, ""); string s2 = reg.Replace(s2_org, ""); reg = new Regex(":1204\\..*\"", RegexOptions.IgnoreCase); s1 = reg.Replace(s1, ":1204\""); s2 = reg.Replace(s2, ":1204\""); //Console.WriteLine(" Compare: result={0}", (s1 == s2 ? "Same" : "Not match")); //for (int i = 0; i < Math.Min(s1.Length, s2.Length); i++) //{ // if (s1[i] != s2[i]) // { // Console.WriteLine(" Diff:\n\r HtmlSource1={0}\n\r HtmlSource2={1}", // s1.Substring(i, (s1.Length - i - 1 >= 20 ? 20 : s1.Length - i - 1)), // s2.Substring(i, (s2.Length - i - 1 >= 20 ? 20 : s2.Length - i - 1))); // break; // } //} //if (s1 != s2) //{ error_count++; string file1 = String.Format("{0}A\\{1}.txt", log_path, error_count); if (File.Exists(file1)) { File.Delete(file1); } FileStream fs = File.Open(file1, FileMode.OpenOrCreate); TextWriter tw = new StreamWriter(fs); tw.WriteLine(title); tw.Write(s1); tw.Flush(); tw.Close(); string file2 = String.Format("{0}B\\{1}.txt", log_path, error_count); if (File.Exists(file2)) { File.Delete(file2); } fs = File.Open(file2, FileMode.OpenOrCreate); tw = new StreamWriter(fs); tw.WriteLine(title); tw.Write(s2); tw.Flush(); tw.Close(); //} return(s1 == s2); }
public ActionResult ParseTourFromUrl(ParseUrlModel model) { selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost"); selenium.Start(); selenium.SetTimeout("120000"); selenium.Open(model.Url); selenium.WaitForPageToLoad("60000"); var html = selenium.GetHtmlSource(); selenium.Stop(); // string html = HtmlDownloader.GetHtml(model.Url); string s = new ForecastParser(QueryFactory, log, UnitOfWorkFactory).ParseHtml(html, model.Url); return(View(new ParseUrlModel { Result = s })); }