protected DownloadFileInfo GetFile(string url, int timeout = Config.TIME_OUT) { WebClientEx web = new WebClientEx(); web.ResetHeaders(); return(new DownloadFileInfo(web, url)); }
private bool CheckUrlContent() { bool isok = true; System.Threading.Thread.Sleep(1000); try { var webClient = new WebClientEx(); foreach (var checkUrl in CheckUrls) { webClient.ResetHeaders(); if (string.IsNullOrEmpty(checkUrl.ContainString)) { webClient.DownloadData(checkUrl.Url); } else { var str = webClient.DownloadString(checkUrl.Url); if (str.Contains(checkUrl.ContainString) == false) { isok = false; break; } } } } catch (Exception e) { isok = false; } return(isok); }
//private string WebPost(string url, string json) //{ // WebClientEx web = new WebClientEx(); // web.ResetHeaders(); // //web.Headers.Add(); // web.Encoding = Encoding.UTF8; // return web.UploadString(url, "POST", json); //} //private string WebPost(string url, object obj) //{ // var json = JsonConvert.SerializeObject(obj); // WebClientEx web = new WebClientEx(); // web.ResetHeaders(); // web.Encoding = Encoding.UTF8; // return web.UploadString(url, "POST", json); //} private string WebGet(string url) { WebClientEx web = new WebClientEx(); web.ResetHeaders(); web.Encoding = Encoding.UTF8; return(web.DownloadString(url)); }
public List <T> LoadUrl(string address) { WebClientEx webClient = new WebClientEx(); webClient.ResetHeaders(); var html = webClient.DownloadString(address); return(LoadData(html)); }
private string WebPost(string url, object obj) { var json = JsonConvert.SerializeObject(obj); WebClientEx web = new WebClientEx(); web.ResetHeaders(); web.Encoding = Encoding.UTF8; return(web.UploadString(url, "POST", json)); }
private string WebPost(string url, string json) { WebClientEx web = new WebClientEx(); web.ResetHeaders(); //web.Headers.Add(); web.Encoding = Encoding.UTF8; return(web.UploadString(url, "POST", json)); }
private string WebUpload(string url, string filePath) { WebClientEx web = new WebClientEx(); web.ResetHeaders(); web.Encoding = Encoding.UTF8; var bytes = web.UploadFile(url, "POST", filePath); return(Encoding.UTF8.GetString(bytes)); }
protected T Post <T>(string url, string post, int timeout = Config.TIME_OUT) where T : class { WebClientEx web = new WebClientEx(); web.ResetHeaders(); web.Encoding = Encoding.UTF8; web.SetTimeOut(timeout); var json = web.UploadString(url, "POST", post); return(Deserialize <T>(json)); }
protected T PostFile <T>(string url, string file, object obj, int timeout = Config.TIME_OUT) where T : class { WebClientEx web = new WebClientEx(); web.ResetHeaders(); web.Encoding = Encoding.UTF8; web.SetTimeOut(timeout); var bytes = web.UploadFile(url, file); var json = Encoding.UTF8.GetString(bytes); return(Deserialize <T>(json)); }