public HtmlDocument GetWebRequest() { HtmlDocument document = new HtmlDocument(); byte[] responseBytes; if (!cache.IsCachedUrl(Url)) { responseBytes = httpClient.DownloadData(Url); CacheDb.SaveCache(Url, responseBytes); } else { responseBytes = cache.GetCachedUrl(Url); } MemoryStream mStream = new MemoryStream(responseBytes); document.Load(mStream); return(document); }
public HtmlDocument GetWebRequest(String Url) { for (int RetryCount = 1; true; RetryCount++) { try { HttpClient httpClient = new HttpClient(); HtmlDocument document = new HtmlDocument(); document.OptionAutoCloseOnEnd = true; document.OptionCheckSyntax = true; document.OptionFixNestedTags = true; //document.OptionWriteEmptyNodes = true; byte[] responseBytes; if (EnableCaching && !cache.IsCachedUrl(Url)) { responseBytes = httpClient.DownloadData(Url); CacheDb.SaveCache(Url, responseBytes); } else if (EnableCaching) { responseBytes = cache.GetCachedUrl(Url); } else { responseBytes = httpClient.DownloadData(Url); } MemoryStream mStream = new MemoryStream(responseBytes); document.Load(mStream); return(document); } catch (Exception ex) { if (RetryCount == MaxRetryCount) { throw ex; } } } }
public Browser() { cache = new CacheDb(); //httpClient = new HttpClient(); EnableCaching = Settings.GetValue("EnableCaching"); }
public Browser(String Url) { cache = new Cache(); httpClient = new HttpClient(); this.Url = Url; }
public Browser() { cache = new CacheDb(); httpClient = new HttpClient(); }