示例#1
0
        public void CallDownloadOnFinish(ICsqWebResponse response)
        {
            string url = response.Url.Substring(0, response.Url.Length - 1);
            int num = int.Parse(response.Url.Substring(response.Url.Length - 1));
            Console.WriteLine(num);

            var dom = response.Dom;
            string imageLink = dom["#comic_page"].Attr("src");
            CQ selector = CQ.Create(dom["select[name='chapter_select']"][0]);
            string chapter = selector["option:Selected"].Text();
            CQ.CreateFromUrlAsync(url + (num+1), CallDownloadOnFinish, DownloadFailed);
            DownloadImageFromLink(imageLink, chapter);
        }
示例#2
0
        //[Test, TestMethod]
        //public void GetCompressedResponseTest()
        //{
        //    CQ mCQ = CQ.CreateFromUrl("http://api.jquery.com/jQuery.contains/");
        //    Assert.IsTrue(mCQ.Select("#jq-footerNavigation").Length == 1, "I found an expected content container - if jQuery changed their web site or compressing method this could fail.");
        //}

        private void FinishRequest(ICsqWebResponse response)
        {
            var csq = response.Dom;

            if ((int)response.Id == 1)
            {
                AsyncStep |= 8;
                Assert.IsTrue(csq.Find(urls[0].Value).Length > 0, "I found an expected content container - if Github changed their web site this could fail.");
            }
            if ((int)response.Id == 2)
            {
                AsyncStep |= 16;
                Assert.IsTrue(csq.Find(urls[1].Value).Length == 1, "I found an expected content container - if CNN changed their web site this could fail.");
            }

            Debug.WriteLine(String.Format("Received Async Response {0} @{1}", response.Id.ToString(), DateTime.Now));
        }
示例#3
0
        private void FinishRequest(ICsqWebResponse response)
        {
            var csq= response.Dom;
            if ((int)response.Id == 1)
            {
                AsyncStep |= 8;
                Assert.IsTrue(csq.Find(".hpMst_Stage").Length == 1, "I found an expected content container - if MS changed their web site this could fail.");

            }
            if ((int)response.Id == 2)
            {
                AsyncStep |= 16;
                Assert.IsTrue(csq.Find("#cnn_hdr").Length == 1, "I found an expected content container - if CNN changed their web site this could fail.");
            }

            Debug.WriteLine(String.Format("Received Async Response {0} @{1}", response.Id.ToString(),DateTime.Now));
        }
示例#4
0
        /// <summary>
        /// Format a single web response
        /// </summary>
        /// <param name="resp"></param>
        /// <returns></returns>
        private string FormatResult(ICsqWebResponse resp)
        {
            string url = resp.Url;

            if (resp.Success)
            {
                CQ dom = resp.Dom;
                return(url + ": " + SelectorTests(dom));
            }
            else
            {
                string httpStatus = resp.HttpStatus > 0 ?
                                    String.Format(" ({0} - {1})",
                                                  resp.HttpStatus,
                                                  resp.HttpStatusDescription) :
                                    "";

                return(String.Format("{0}: failed with error \"{1}\"{2}",
                                     url,
                                     resp.Error,
                                     httpStatus));
            }
        }
示例#5
0
 public void DownloadFailed(ICsqWebResponse response)
 {
     Console.WriteLine(response.Url);
 }
示例#6
0
        /// <summary>
        /// Format a single web response
        /// </summary>
        /// <param name="resp"></param>
        /// <returns></returns>
        private string FormatResult(ICsqWebResponse resp)
        {
            string url = resp.Url;
            
            if (resp.Success)
            {
                CQ dom = resp.Dom;
                return url + ": " + SelectorTests(dom);
            }
            else
            {
                string httpStatus = resp.HttpStatus > 0 ?
                    String.Format(" ({0} - {1})",
                        resp.HttpStatus,
                        resp.HttpStatusDescription) :
                        "";

                return String.Format("{0}: failed with error \"{1}\"{2}",
                    url,
                    resp.Error,
                     httpStatus);
            }
        }