Example #1
0
        /// <summary>
        /// Parses volume information based on its title element.
        /// </summary>
        /// <param name="hEl"></param>
        public Volume(CQ ul)
        {
            ul.Find("li").Each((el) =>
            {
                var link = new CQ(el).Find("a").First();
                if (link.Count() == 0) return;

                var name = Regex.Replace(link.Attr("href"), "^.+title=", "");

                if (name.Contains("Illustrations") && _illustrationsPage == null)
                {
                    _illustrationsPage = new IllustrationsPage(name);
                }
                else
                {
                    _chapters.Add(new Chapter(name, link.Text()));
                }
            });
        }
        private bool DetermineIfMessageIsCloseVoteRequest(CQ messageContentsNode)
        {
            //message contains "cv-pls", "cv-plz", or "close", and has a link

            var triggerPhrases = new[]
            {
                "cv-pls",
                "cv-plz",
                "close"
            };

            var text = messageContentsNode.Text();

            var hasTriggerPhrase = triggerPhrases
                .Select(x => text.Contains(x))
                .Any(x => x);

            var hasLink = messageContentsNode.Find("a").Any();

            return hasTriggerPhrase && hasLink;
        }
 private static ParsedRSSFeedLink ParseLink(IDomObject linkNode)
 {
     ParsedRSSFeedLink parsedRSSFeedLink;
     CQ linkCq = new CQ(linkNode.Clone());
     CQ aCq = linkCq.Find("a");
     if (aCq.Any())
     {
         ParsedRSSFeedLink parsedRSSFeedLink1 = new ParsedRSSFeedLink
         {
             LinkURL = aCq.Attr<string>("href"),
             LinkTitle = aCq.First().Text()
         };
         ParsedRSSFeedLink link = parsedRSSFeedLink1;
         aCq.FirstElement().Remove();
         link.Description = linkCq.Text().Trim();
         parsedRSSFeedLink = link;
     }
     else
     {
         parsedRSSFeedLink = null;
     }
     return parsedRSSFeedLink;
 }
Example #4
0
        public void Contents()
        {
           
            Assert.AreEqual(jQuery("#ap").Contents().Length, 9, "Check element contents" );
            Assert.IsTrue( jQuery("#iframe").Length>0, "Check existence of IFrame document" );

            jQuery("#loadediframe").Append(@"<html>
              <head>
                <title>iframe</title>
              </head>
              <body>
                <div><span>span text</span></div>
              </body>
            </html>");
            
            var ibody = jQuery("#loadediframe").Contents().Find("body");
            Assert.IsTrue( ibody.Length>0, "Check existance of IFrame body" );
            var csq = new CQ("span", ibody);
            Assert.AreEqual(csq.Text(), "span text", "Find span in IFrame and check its text" );

            jQuery(ibody).Append("<div>init text</div>");
            csq = new CQ("div", ibody);
            Assert.AreEqual(csq.Length, 2, "Check the original div and the new div are in IFrame" );
            csq = new CQ("div:last", ibody);
            Assert.AreEqual(csq.Text(), "init text", "Add text to div in IFrame" );

            csq = new CQ("div:last", ibody);
            csq.Text("div text");
            Assert.AreEqual(new CQ("div:last", ibody).Text(), "div text", "Add text to div in IFrame");

            csq = new CQ("div:last", ibody).Remove();
            Assert.AreEqual(jQuery("div",ibody).Length, 1, "Delete the div and check only one div left in IFrame" );

            Assert.AreEqual(jQuery("div",ibody).Text(), "span text", "Make sure the correct div is still left after deletion in IFrame" );

            csq = new CQ("<table/>", ibody);
            csq.Append("<tr><td>cell</td></tr>").AppendTo(ibody);
            csq = new CQ("table", ibody);
            csq.Remove();
            csq = new CQ("div", ibody);
            Assert.AreEqual(csq.Length, 1, "Check for JS error on add and delete of a table in IFrame" );

            // using contents will get comments regular, text, and comment nodes
            var c = jQuery("#nonnodes").Contents().Contents();
            Assert.AreEqual(c.Length, 1, "Check node,textnode,comment contents is just one" );
            Assert.AreEqual(c[0].NodeValue, "hi", "Check node,textnode,comment contents is just the one from span" );
        }
        /// <summary>Get and process app information in public store web page</summary>
        /// <param name="storeApp">Object to complete fields with all information taken from app web page</param>
        /// <param name="dom">C# query object used to explore DOM from Store App web page</param>
        public override void ObjectDOMMapper(IStoreApp storeApp, CQ dom)
        {
            storeApp.Name = dom["h1[itemprop='name']"].Text();
            storeApp.Author = dom["#AppDeveloper"].Text().Trim();
            storeApp.ThumbnailUri = new Uri(dom["img#ScreenshotImage"].Attr("src"));

            //from here working in windows store specific fields
            var winstoreApp = storeApp as WindowsStoreApp;
            if (winstoreApp != null)
            {
                //converting DOM object in string
                string strTargetString = dom.Text();
                //using regular expression to extract PFN
                winstoreApp.PackageFamilyName = InfoExtractor.Match(strTargetString).Groups[1].Value;
            }
        }