Esempio n. 1
0
        private async Task <HttpWebResponse> GetResponseAsync(string name)
        {
            WebPage webPage = GetVariable(name, "webpage") as WebPage;

            Output?.Invoke(this, $"get response of web page {webPage}");

            return(await HtmlGetter.GetResponseAsync(webPage));
        }
Esempio n. 2
0
        private async Task <string> GetResponseTextAsync(string name)
        {
            WebPage webPage = GetVariable(name, "webpage") as WebPage;

            string value = await HtmlGetter.GetResponseTextAsync(webPage);

            Output?.Invoke(this, $"get response text of web page {webPage}");
            return(value);
        }
Esempio n. 3
0
        public static object GetResponseBySetting(WebPage webPage)
        {
            HtmlGetter parser = new HtmlGetter(webPage);

            byte[] response = parser.GetResponseBinary();
            if (webPage.Response_Type == ResponseType.Binary)
            {
                return(response);
            }
            return(Config.Instance.Encoding.GetString(response));
        }
Esempio n. 4
0
        //public static HtmlDocument GetHtmlDocument(WebPage webPage)
        //{
        //    HtmlGetter parser = new HtmlGetter(webPage);
        //    string html = parser.GetResponseText();
        //    var doc = new HtmlDocument();
        //    doc.LoadHtml(html);
        //    return doc;
        //}
        //public async static Task<HtmlDocument> GetHtmlDocumentAsync(WebPage webPage)
        //{
        //    HtmlGetter parser = new HtmlGetter(webPage);
        //    string html =await parser.GetResponseTextAsync();
        //    var doc = new HtmlDocument();
        //    doc.LoadHtml(html);
        //    return doc;
        //}
        //public static JToken GetJson(WebPage webPage)
        //{
        //    HtmlGetter parser = new HtmlGetter(webPage);
        //    string json = parser.GetResponseText();
        //    try
        //    {
        //        return JToken.Parse(json);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception("转换为JSON失败", ex);
        //    }
        //}
        //public async static Task<JToken> GetJsonAsync(WebPage webPage)
        //{
        //    HtmlGetter parser = new HtmlGetter(webPage);
        //    string json =await parser.GetResponseTextAsync();
        //    try
        //    {
        //        return JToken.Parse(json);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception("转换为JSON失败", ex);
        //    }
        //}
        public static string GetResponseText(WebPage webPage)
        {
            HtmlGetter parser = new HtmlGetter(webPage);

            byte[] response = parser.GetResponseBinary();
            if (webPage.Response_Type == ResponseType.Binary)
            {
                return(Convert.ToBase64String(response));
            }
            return(Config.Instance.Encoding.GetString(response));
        }
Esempio n. 5
0
        public async static Task <object> GetResponseBySettingAsync(WebPage webPage)
        {
            HtmlGetter parser = new HtmlGetter(webPage);

            byte[] response = await parser.GetResponseBinaryAsync();

            if (webPage.Response_Type == ResponseType.Binary)
            {
                return(response);
            }
            return(Config.Instance.Encoding.GetString(response));
        }
Esempio n. 6
0
 public async static Task <CompareResult> CompareAsync(WebPage webPage)
 {
     byte[] newContent;
     try
     {
         newContent = await HtmlGetter.GetResponseBinaryAsync(webPage);
     }
     catch (Exception ex)
     {
         throw new WebPageException("ex_getContentFailed", webPage, ex);
     }
     return(await CompareAsync(webPage, webPage.GetLatestContent(), newContent));
 }
Esempio n. 7
0
        public static byte[] GetResponseBinary(WebPage webPage)
        {
            HtmlGetter parser = new HtmlGetter(webPage);

            return(parser.GetResponseBinary());
        }
Esempio n. 8
0
        public async static Task <HttpWebResponse> GetResponseAsync(WebPage webPage)
        {
            HtmlGetter parser = new HtmlGetter(webPage);

            return(await parser.GetResponseAsync());
        }
Esempio n. 9
0
        public static HttpWebResponse GetResponse(WebPage webPage)
        {
            HtmlGetter parser = new HtmlGetter(webPage);

            return(parser.GetResponse());
        }
Esempio n. 10
0
        public async static Task <byte[]> GetResponseBinaryAsync(WebPage webPage)
        {
            HtmlGetter parser = new HtmlGetter(webPage);

            return(await parser.GetResponseBinaryAsync());
        }