Beispiel #1
0
        public void Issue28()
        {
            var strFilePath = Support.GetFilePath(SolutionDirectory + "\\CsQuery.Tests\\Resources\\pupillogin.htm");

            var    objStreamReader = new StreamReader(strFilePath, Encoding.UTF8);
            string str             = objStreamReader.ReadToEnd();
            var    dom             = CQ.Create(str);
        }
Beispiel #2
0
        public void ClassAndStyleAsBoolean()
        {
            string html   = @"<span class="""" style="""">Test </span><div class style><br /></div>";
            var    dom    = CQ.Create(html);
            var    output = dom.Render(OutputFormatters.Create(HtmlEncoders.Minimum)).Replace("" + (char)160, "&nbsp;");

            Assert.AreEqual(@"<span style>Test </span><div style><br></div>", output);
        }
Beispiel #3
0
        public void RountripEncoding()
        {
            string html   = "<span>Test &nbsp; nbsp</span>";
            var    dom    = CQ.Create(html);
            var    output = dom.Render(OutputFormatters.Create(HtmlEncoders.Minimum)).Replace("" + (char)160, "&nbsp;");

            Assert.AreEqual(html, output);
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object"/> class.
        /// </summary>
        public AssertExtensionsTests()
        {
            var document =
                CQ.Create(@"<html><head></head><body><div id='testId' class='myClass' attribute1 attribute2='value2'>Test</div><div class='anotherClass'>Tes</div><span class='class'>some contents</span><span class='class'>This has contents</span></body></html>");

            this.query =
                new QueryWrapper(document);
        }
Beispiel #5
0
        public void EmptyByDefault()
        {
            var cq = CQ.Create("<div></div>");

            int length = cq.FirstElement().Annotations.Length;

            Assert.AreEqual(0, length, "annotations is not empty");
        }
Beispiel #6
0
        public static void ReadLargeDoc(TestContext context)
        {
            // CsQuery (version 1.3.0 and above) uses this code.

            Dom = CQ.Create(
                CsQuery.Utility.Support.GetFile("HtmlParserSharp.Tests\\Resources\\html standard.htm")
                );
        }
Beispiel #7
0
        public void CaseInsensitive()
        {
            var dom = CQ.Create(@"<input type='checkbox' checked='checked' name='stuff' />
        <input type='Checkbox' checked='Checked' name='Stuff' />");

            Assert.AreEqual(2, dom["input[type='checkbox']"].Length);
            Assert.AreEqual(1, dom["input[name='stuff']"].Length);
        }
Beispiel #8
0
        public void Utf8_HighValues()
        {
            string html   = @"<span>&#55449;&#56580;</span>";
            var    dom    = CQ.Create(html);
            var    output = dom.Render();

            Assert.AreEqual(@"<span>&#65533;&#65533;</span>", output);
        }
        private string GetPriceText(string uri)
        {
            var html         = this.DownloadString(uri);
            var cq           = CQ.Create(html);
            var priceElement = cq.Select("[itemprop=price]");

            return(priceElement.Text().Trim());
        }
        public void ExplicitFormIdIgnoredOnNonFormReassociateable()
        {
            CQ cq = CQ.Create("<form id=a><div><label form=b></div></form><form id=b></form>");
            IHTMLLabelElement label = cq["label"].FirstElement() as IHTMLLabelElement;

            Assert.IsNotNull(label);
            Assert.IsNotNull(label.Form);
            Assert.AreEqual("a", label.Form.Id);
        }
Beispiel #11
0
        /// <summary>
        /// Loads both CSQ and HAP documents
        /// </summary>
        /// <param name="doc"></param>
        public void LoadBoth(string doc)
        {
            var html = Support.GetFile(Program.ResourceDirectory + "\\" + doc + ".htm");

            CsqueryDocument = CQ.Create(html);

            HapDocument = new HtmlDocument();
            HapDocument.LoadHtml(html);
        }
Beispiel #12
0
        private void StartAnalize(WebContent content, HttpClient httpClient, string baseUrl)
        {
            CQ html = CQ.Create(content.Text);

            FindCss(html, httpClient, baseUrl);
            FindJavaScript(html, httpClient, baseUrl);
            FindAnchors(html, httpClient, baseUrl);
            IsPageReaded = false;
        }
        public void ExplicitFormIdSpecified()
        {
            CQ cq = CQ.Create("<form id=a><div><input form=b></div></form><form id=b></form>");
            IHTMLInputElement input = cq["input"].FirstElement() as IHTMLInputElement;

            Assert.IsNotNull(input);
            Assert.IsNotNull(input.Form);
            Assert.AreEqual("b", input.Form.Id);
        }
Beispiel #14
0
        public void DefaultSubmitType()
        {
            CQ cq = CQ.Create("<button>Boo!</button>");
            IHTMLButtonElement buttonElement = cq["button"].FirstElement() as IHTMLButtonElement;

            Assert.IsNotNull(buttonElement);
            Assert.AreEqual("submit", buttonElement.Type);
            Assert.IsFalse(buttonElement.HasAttribute("type"));
        }
        public void OptionSharesFormOfSelect()
        {
            CQ cq = CQ.Create("<form id=a><select form=b><option></option></select></form><form id=b></form>");
            IHTMLOptionElement option = cq["option"].FirstElement() as IHTMLOptionElement;

            Assert.IsNotNull(option);
            Assert.IsNotNull(option.Form);
            Assert.AreEqual("b", option.Form.Id);
        }
Beispiel #16
0
        public void Add()
        {
            Assert.AreEqual(jQuery("#sndp").Add("#en").Add("#sap").Get(), q("sndp", "en", "sap"), "Check elements from document");
            Assert.AreEqual(jQuery("#sndp").Add(jQuery("#en")[0]).Add(jQuery("#sap")).Get(), q("sndp", "en", "sap"), "Check elements from document");

            // We no longer support .Add(form.elements), unfortunately.
            // There is no way, in browsers, to reliably determine the difference
            // between form.elements and form - and doing .Add(form) and having it
            // add the form elements is way to unexpected, so this gets the boot.
            // ok( jQuery([]).Add(jQuery("#form")[0].elements).Length >= 13, "Check elements from array" );

            // For the time being, we're discontinuing support for jQuery(form.elements) since it's ambiguous in IE
            // use jQuery([]).Add(form.elements) instead.
            //Assert.AreEqual(jQuery([]).Add(jQuery("#form")[0].elements).Length, jQuery(jQuery("#form")[0].elements).Length, "Array in constructor must equals array in add()" );

            //TODO: It would be nice to have a ParentNode exist & be typed to 11 for disconnected nodes. However this creates some complexity
            //b/c we still need to keep the nodes conceptually bound to another domain. I think that we may want a special "disconnected" heirarchy
            //within and IDomRoot. For now just compare to null instead.

            var divs = jQuery("<div/>").Add("#sndp");

            //Assert.IsTrue( (int)divs[0].ParentNode.NodeType ==11, "Make sure the first element is still the disconnected node." );
            Assert.IsTrue(divs[0].ParentNode == null, "Make sure the first element is still the disconnected node.");

            divs = jQuery("<div>test</div>").Add("#sndp");
            //Assert.AreEqual((int)divs[0].ParentNode.NodeType, 11, "Make sure the first element is still the disconnected node." );
            Assert.AreEqual(divs[0].ParentNode, null, "Make sure the first element is still the disconnected node.");

            divs = jQuery("#sndp").Add("<div/>");
            Assert.IsTrue(divs[1].ParentNode == null, "Make sure the first element is still the disconnected node.");

            var tmp = jQuery("<div/>");

            var x = CQ.Create().Add(jQuery("<p id='x1'>xxx</p>").AppendTo(tmp)).Add(jQuery("<p id='x2'>xxx</p>").AppendTo(tmp));

            Assert.AreEqual(x[0].Id, "x1", "Check on-the-fly element1");
            Assert.AreEqual(x[1].Id, "x2", "Check on-the-fly element2");

            x = CQ.Create().Add(jQuery("<p id='x1'>xxx</p>").AppendTo(tmp)[0]).Add(jQuery("<p id='x2'>xxx</p>").AppendTo(tmp)[0]);
            Assert.AreEqual(x[0].Id, "x1", "Check on-the-fly element1");
            Assert.AreEqual(x[1].Id, "x2", "Check on-the-fly element2");

            x = CQ.Create().Add(jQuery("<p id='x1'>xxx</p>")).Add(jQuery("<p id='x2'>xxx</p>"));
            Assert.AreEqual(x[0].Id, "x1", "Check on-the-fly element1");
            Assert.AreEqual(x[1].Id, "x2", "Check on-the-fly element2");

            x = CQ.Create().Add("<p id='x1'>xxx</p>").Add("<p id='x2'>xxx</p>");
            Assert.AreEqual(x[0].Id, "x1", "Check on-the-fly element1");
            Assert.AreEqual(x[1].Id, "x2", "Check on-the-fly element2");

            IDomElement notDefined = null;

            Assert.AreEqual(CQ.Create().Add(notDefined).Length, 0, "Check that undefined adds nothing");

            Assert.AreEqual(CQ.Create().Add(document.GetElementById("form")).Length, 1, "Add a form");
            Assert.AreEqual(CQ.Create().Add(document.GetElementById("select1")).Length, 1, "Add a select");
        }
        public List <string> ParseMangaList(string response)
        {
            var localcq = CQ.Create(response);

            return(localcq
                   .Find(".title_link")
                   .Select(x => $"https://mangachan.me{x.GetAttribute("href")}")
                   .ToList());
        }
Beispiel #18
0
        public void Type()
        {
            CQ cq = CQ.Create("<textarea type=useless>Foo that bar</textarea>");
            IHTMLTextAreaElement textArea = cq["textarea"].FirstElement() as IHTMLTextAreaElement;

            Assert.IsNotNull(textArea);
            Assert.AreEqual("textarea", textArea.Type);
            Assert.AreEqual("useless", textArea.GetAttribute("type"));
        }
Beispiel #19
0
        private async Task <bool> SearchResultsExist(HttpResponseMessage initialSearchResponse)
        {
            var initialSearchResponseHtml = await initialSearchResponse.Content.ReadAsStringAsync();

            var initialSearchPageResponseDoc = CQ.Create(initialSearchResponseHtml);
            var searchResultList             = initialSearchPageResponseDoc.Select("#searchresults");

            return(searchResultList.Length != 0);
        }
Beispiel #20
0
        public static void GetCurrTestResult(string url)
        {
            string ResultUrl = url;


            string     html;
            WebRequest request = WebRequest.Create(ResultUrl);

            request.Credentials = CredentialCache.DefaultCredentials;
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (Stream dataStream = response.GetResponseStream())
            {
                using (StreamReader reader = new StreamReader(dataStream))
                {
                    html = reader.ReadToEnd();
                }
            }
            response.Close();


            CQ cq = CQ.Create(html);

            /* FIRST VARIABLE
             * foreach (IDomObject tdElement in cq.Find("div"))
             * {
             *  if (tdElement.ClassName == "dSolidGaugePercent")
             *  {
             *      var ss = tdElement.GetAttribute("sgp-percent");
             *  }
             * }*/

            int count = 0;
            int rest;

            foreach (IDomObject tdElement in cq.Find("td"))
            {
                if (tdElement.ClassName == "ta-c")
                {
                    count++;
                    if (count == 3)
                    {
                        rest = int.Parse(tdElement.InnerText.Replace(System.Environment.NewLine, "")) % 10;

                        if (rest >= 5)
                        {
                            Repository.testResult = (int.Parse(tdElement.InnerText.Replace(System.Environment.NewLine, "")) / 10 + 1);
                        }
                        else
                        {
                            Repository.testResult = int.Parse(tdElement.InnerText.Replace(System.Environment.NewLine, "")) / 10;
                        }
                        break;
                    }
                }
            }
        }
Beispiel #21
0
        public void SiblingsSelf()
        {
            var dom = CQ.Create("<table><tr id=1><tr id=2><tr id=3></table>");

            var res = dom["table tr+tr"];

            Assert.AreEqual(2, res.Length);
            CollectionAssert.AreEqual(Arrays.String("2", "3"), res.Select(item => item.Id).ToList());
        }
        public IEnumerable <string> FindHtmlPageLinks(string html)
        {
            var csQuery = CQ.Create(html);

            foreach (var domObject in csQuery.Find("a"))
            {
                yield return(domObject.GetAttribute("href"));
            }
        }
Beispiel #23
0
        public void Create_Stream()
        {
            byte[] byteArray = Encoding.Unicode.GetBytes(divDom);
            Stream stream    = new MemoryStream(byteArray);

            var div = CQ.Create(stream, Encoding.Unicode);

            Assert.AreEqual(divDom, div.Render());
        }
Beispiel #24
0
        public void LowercaseType()
        {
            CQ cq = CQ.Create("<button type=SEARCH>Boo!</button>");
            IHTMLButtonElement buttonElement = cq["button"].FirstElement() as IHTMLButtonElement;

            Assert.IsNotNull(buttonElement);
            Assert.AreEqual("search", buttonElement.Type);
            Assert.AreEqual("SEARCH", buttonElement.GetAttribute("type"));
        }
Beispiel #25
0
        public void ProcessDetailsSingle(int torrentId)
        {
            _logger.Info("Detailing torrent #{0}", torrentId);

            Torrent torrent;

            using (var db = new DbTorronto())
            {
                torrent = db.Torrent.First(t => t.ID == torrentId);
            }

            if (torrent == null)
            {
                _logger.Warn("No such torrent #{0}", torrentId);
                return;
            }

            using (var client = GetClient())
            {
                var response = client.GetAsync("torrent/" + torrent.SiteID).Result;

                if (response.IsSuccessStatusCode)
                {
                    var content = response.Content.ReadAsStringAsync().Result;
                    var dom     = CQ.Create(content, Encoding.UTF8);

                    var links = dom["#details a"];
                    var title = (dom["title"].Select(x => x.InnerText).FirstOrDefault() ?? string.Empty).ToLower();

                    int?imdbId, kinopoiskId;

                    FillExternalMovieIds(links, out imdbId, out kinopoiskId);

                    var quality = _qualityDetector.Detect(dom);

                    if (torrent.Category == TorrentCategory.Russian)
                    {
                        quality.TranslationQuality = Translation.Dub;
                    }

                    torrent.ImdbID       = imdbId;
                    torrent.KinopoiskID  = kinopoiskId;
                    torrent.VideoQuality = quality.VideoQuality;
                    torrent.AudioQuality = quality.AudioQuality;
                    torrent.Translation  = quality.TranslationQuality;

                    var isRemoved = title.Contains("не существует");

                    _torrentService.SaveDetails(torrent, isRemoved);

                    QueueService.AddTorrentForReindex(torrentId);
                    QueueService.AddTorrentForMatch(torrentId);

                    File.WriteAllText(Path.Combine("html", "torrents", torrentId + ".html"), content);
                }
            }
        }
Beispiel #26
0
        public void TestInvalidID2()
        {
            string html = @"<div id=""test""></div><div id=""test""></div>";
            var    dom  = CQ.Create(html);

            var res = dom["#test"];

            Assert.AreEqual(2, res.Length);
        }
        public void ClosestForm()
        {
            CQ cq = CQ.Create("<form id=parent><div><input></div></form>");
            IHTMLInputElement input = cq["input"].FirstElement() as IHTMLInputElement;

            Assert.IsNotNull(input);
            Assert.IsNotNull(input.Form);
            Assert.AreEqual("parent", input.Form.Id);
        }
Beispiel #28
0
        public void Issue57()
        {
            var document = CQ.Create(@"<div xmlns=""http://www.w3.org/1999/xhtml"" id=""content"" class=""results""><table><thead><tr><th><a href=""/uksi/2007-*?sort=title"" class=""sortAsc"" title=""Sort ascending by Title""><span class=""accessibleText"">Sort ascending by </span>Title</a></th><th><span>Years and Numbers</span></th><th><span>Legislation type</span></th></tr></thead><tbody><tr class=""oddRow""><td><a href=""/uksi/2012/2652/contents/made"">The Motor Vehicles (Tests) (Amendment) (No. 2) Regulations 2012</a></td><td><a href=""/uksi/2012/2652/contents/made"">2012 No. 2652</a></td><td>UK Statutory Instruments</td></tr><tr><td><a href=""/uksi/2012/2651/contents/made"">The A259 Trunk Road (Various Roads, Rye) (Temporary Restriction and Prohibition of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2651/contents/made"">2012 No. 2651</a></td><td>UK Statutory Instruments</td></tr><tr class=""oddRow""><td><a href=""/uksi/2012/2650/contents/made"">The A21 Trunk Road (Northbridge Street Roundabout) (Temporary Prohibition of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2650/contents/made"">2012 No. 2650</a></td><td>UK Statutory Instruments</td></tr><tr><td><a href=""/uksi/2012/2649/contents/made"">The M4 Motorway (Junction 10, Link Roads) (Temporary Prohibition of Traffic) (No.3) Order 2012</a></td><td><a href=""/uksi/2012/2649/contents/made"">2012 No. 2649</a></td><td>UK Statutory Instruments</td></tr><tr class=""oddRow""><td><a href=""/uksi/2012/2648/contents/made"">The M4 Motorway (Junction 4, Eastbound Exit Slip Road) (Temporary Prohibition of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2648/contents/made"">2012 No. 2648</a></td><td>UK Statutory Instruments</td></tr><tr><td><a href=""/uksi/2012/2647/contents/made"">The Health Act 2009 (Commencement No. 6) Order 2012</a></td><td><a href=""/uksi/2012/2647/contents/made"">2012 No. 2647 (C. 105)</a></td><td>UK Statutory Instruments</td></tr><tr class=""oddRow""><td><a href=""/uksi/2012/2646/contents/made"">The A26 Trunk Road (Beddingham Roundabout - South of The Lay) (Temporary 40 Miles Per Hour Speed Restriction) Order 2012</a></td><td><a href=""/uksi/2012/2646/contents/made"">2012 No. 2646</a></td><td>UK Statutory Instruments</td></tr><tr><td><a href=""/uksi/2012/2645/contents/made"">The M6 Motorway (Junction 20-22 Southbound Carriageway and Slip Road) (Temporary Prohibition and Restriction of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2645/contents/made"">2012 No. 2645</a></td><td>UK Statutory Instruments</td></tr><tr class=""oddRow""><td><a href=""/uksi/2012/2644/contents/made"">The M62 Motorway (Junction 32 to Junction 33) (Temporary Prohibition of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2644/contents/made"">2012 No. 2644</a></td><td>UK Statutory Instruments</td></tr><tr><td><a href=""/uksi/2012/2643/contents/made"">The M18 Motorway (Junction 2, Wadworth) (Temporary Restriction and Prohibition of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2643/contents/made"">2012 No. 2643</a></td><td>UK Statutory Instruments</td></tr><tr class=""oddRow""><td><a href=""/uksi/2012/2642/contents/made"">The M1 Motorway and the M18 Motorway (Thurcroft Interchange to Bramley Interchange) (Temporary Restriction and Prohibition of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2642/contents/made"">2012 No. 2642</a></td><td>UK Statutory Instruments</td></tr><tr><td><a href=""/uksi/2012/2641/contents/made"">The M1 Motorway (Junction 32 to Junction 33) and the M18 Motorway (Thurcroft Interchange to Junction 1) (Temporary Restriction and Prohibition of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2641/contents/made"">2012 No. 2641</a></td><td>UK Statutory Instruments</td></tr><tr class=""oddRow""><td><a href=""/uksi/2012/2640/contents/made"">The A1 Trunk Road (Darrington Interchange) (Temporary Prohibition of Traffic) (No.2) Order 2012</a></td><td><a href=""/uksi/2012/2640/contents/made"">2012 No. 2640</a></td><td>UK Statutory Instruments</td></tr><tr><td><a href=""/uksi/2012/2639/contents/made"">The A1 Trunk Road (Catterick South Interchange) (Temporary Restriction and Prohibition of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2639/contents/made"">2012 No. 2639</a></td><td>UK Statutory Instruments</td></tr><tr class=""oddRow""><td><a href=""/uksi/2012/2638/contents/made"">The A1 Trunk Road (Gateshead Quays Interchange) (Temporary Prohibition of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2638/contents/made"">2012 No. 2638</a></td><td>UK Statutory Instruments</td></tr><tr><td><a href=""/uksi/2012/2637/contents/made"">The A1 Trunk Road (West Mains to Haggerston) (Temporary Restriction and Prohibition of Traffic) Order 2012</a></td><td><a href=""/uksi/2012/2637/contents/made"">2012 No. 2637</a></td><td>UK Statutory Instruments</td></tr><tr class=""oddRow""><td><a href=""/uksi/2012/2636/contents/made"">The Merchant Shipping (Passenger Ships on Domestic Voyages)(Amendment) Regulations 2012</a></td><td><a href=""/uksi/2012/2636/contents/made"">2012 No. 2636</a></td><td>UK Statutory Instruments</td></tr><tr><td><a href=""/uksi/2012/2635/contents/made"">The Network Rail (North Doncaster Chord) Order 2012</a></td><td><a href=""/uksi/2012/2635/contents/made"">2012 No. 2635</a></td><td>UK Statutory Instruments</td></tr><tr class=""oddRow""><td class=""bilingual en""><a href=""/wsi/2012/2634/contents/made"">The A470 Trunk Road (Llyswen, Powys) (Temporary Prohibition of Vehicles) Order 2012</a></td><td rowspan=""2""><a href=""/wsi/2012/2634/contents/made"">2012 No. 2634</a></td><td rowspan=""2"">Wales Statutory Instruments</td></tr><tr class=""oddRow""><td class=""bilingual cy""><a href=""/wsi/2012/2634/contents/made/welsh"" lang=""cy"" xml:lang=""cy"" xmlns:xml=""http://www.w3.org/XML/1998/namespace"">Gorchymyn Cefnffordd yr A470 (Llys-wen, Powys) (Gwahardd Cerbydau Dros Dro) 2012</a></td></tr><tr><td class=""bilingual en""><a href=""/wsi/2012/2633/contents/made"">The A40 Trunk Road (Glangwili Roundabout to Broad Oak, Carmarthenshire) (Temporary Traffic Restrictions and Prohibitions) Order 2012</a></td><td rowspan=""2""><a href=""/wsi/2012/2633/contents/made"">2012 No. 2633</a></td><td rowspan=""2"">Wales Statutory Instruments</td></tr><tr><td class=""bilingual cy""><a href=""/wsi/2012/2633/contents/made/welsh"" lang=""cy"" xml:lang=""cy"" xmlns:xml=""http://www.w3.org/XML/1998/namespace"">Gorchymyn Cefnffordd yr A40 (Cylchfan Glangwili i Dderwen-fawr, Sir Gaerfyrddin) (Cyfyngiadau a Gwaharddiadau Traffig Dros Dro) 2012</a></td></tr></tbody></table></div>");

            var elem = document["#content.results > table > tbody > tr > td:nth-child(1) > a:nth-child(1)"].Eq(19).Parent().Next("td").Children("a").First();
            // Do something with elem
            var link = elem.Parent().Next("td").Children("a").First();
            // NullReferenceException thrown.
        }
Beispiel #29
0
        public async Task <IEnumerable <PlanningApplication> > ExtractDataAsync(string searchArea, List <HttpResponseMessage> searchResultPages, CookieContainer cookieContainer, CancellationToken cancellationToken)
        {
            try
            {
                _configuration = _configResolver.ResolveConfig(searchArea);

                var currentPage = 0;

                await _logger.LogInformationAsync($"Processing {searchResultPages.Count} search result pages for {searchArea.ToUpper()}", cancellationToken);

                var client = HttpClientHelpers.CreateClient(_configuration.BaseUri, _systemConfig, _configuration, _logger, cookieContainer);

                foreach (var searchResults in searchResultPages)
                {
                    currentPage++;
                    var searchResultsHtml = await searchResults.Content.ReadAsStringAsync();

                    var searchPageResponseDoc = CQ.Create(searchResultsHtml);
                    var appSummaryPaths       = GetAppSummaryPaths(searchPageResponseDoc);

                    await _logger.LogInformationAsync($"Found {appSummaryPaths.Count} planning applications in page {currentPage}...", cancellationToken);

                    var row = 0;
                    foreach (var appSummaryPath in appSummaryPaths)
                    {
                        row++;
                        var planningApplication = new PlanningApplication();
                        await _logger.LogInformationAsync($"Getting application detail for result number {row} application {appSummaryPath}", cancellationToken);

                        await ExtractApplicationSummary(cancellationToken, appSummaryPath, client, planningApplication);

                        var appDetailsPath = await ExtractApplicationDetails(cancellationToken, appSummaryPath, client, planningApplication);

                        await ExtractApplicationContact(cancellationToken, appDetailsPath, client, planningApplication);

                        _planningApplications.Add(planningApplication);

                        if (_configuration.UseProxy)
                        {
                            // refresh client/handler to get a new IP address
                            client = HttpClientHelpers.CreateClient(_configuration.BaseUri, _systemConfig, _configuration, _logger, cookieContainer);
                        }
                    }
                }

                await _logger.LogInformationAsync($"Finished extracting planning data for {searchArea.ToUpper()}...", cancellationToken);

                client.Dispose();

                return(_planningApplications);
            }
            catch (Exception ex)
            {
                throw new ExtractDataFailedException(ex.Message, ex.InnerException);
            }
        }
Beispiel #30
0
        public void DisconnectedBefore()
        {
            string s   = "This is <b> a big</b> text";
            var    dom = CQ.Create(s);
            var    res = dom[dom.Document];
            var    el  = dom.Document.CreateElement("code");

            res = res.Before(el);
            CollectionAssert.AreEqual(Objects.Enumerate(el, dom.Document), res.ToList());
        }