Пример #1
0
        public void Login()
        {
            Dictionary<string, string> parameters;

            // show login dialog
            using (InsiderLoginDialog d = new InsiderLoginDialog())
            {
                if (d.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    throw new ApplicationException("User refused Insider login");

                parameters = new Dictionary<string, string>();
                parameters["email"] = d.Email;
                parameters["password"] = d.Password;
                parameters["InsiderSignin"] = "Sign In";
            }

            // perform login page GET to get event validation
            using (HttpWebResponse response = HttpHelper.UrlGet(URL_LOGIN, m_cookies))
            {
                // extract the validation parameter from the response stream
                using (Stream s = response.GetResponseStream())
                {
                    HtmlDocument doc;
                    XPathNavigator nav_view, nav_event;
                    const string NAME_VIEW = "__VIEWSTATE";
                    const string NAME_EVENT = "__EVENTVALIDATION";

                    // read in the login page HTML
                    doc = new HtmlDocument();
                    doc.Load(s);

                    // select the elements we want to read
                    nav_view = doc.CreateNavigator().SelectSingleNode("//input[@name = '" + NAME_VIEW + "']");
                    nav_event = doc.CreateNavigator().SelectSingleNode("//input[@name = '" + NAME_EVENT + "']");

                    // if there was no such node, we're screwed
                    if (nav_view == null || nav_event == null)
                        throw new ApplicationException("Can't find parameters in login page");

                    // set value
                    parameters[NAME_VIEW] = nav_view.SelectSingleNode("@value").Value;
                    parameters[NAME_EVENT] = nav_event.SelectSingleNode("@value").Value;
                }
            }

            // perform login request and grab the resulting cookie(s)
            using (HttpWebResponse response = HttpHelper.UrlPost(URL_LOGIN, parameters, false, m_cookies))
            {
                // pass for now, should probably do some validation later
            }
        }
Пример #2
0
        /// <summary>
        /// 根据 html 字符串创建
        /// </summary>
        /// <remarks>Hesinx 2016-05-26</remarks>
        /// <param name="navigator">(null as HtmlNodeNavigator)</param>
        /// <param name="html"></param>
        /// <returns></returns>
        public static HtmlNodeNavigator Create(this HtmlNodeNavigator navigator, string html)
        {
            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(html);
            return(doc.CreateNavigator() as HtmlNodeNavigator);
        }
Пример #3
0
        private List<user> ParseUserPage(string html)
        {
            List<user> list = new List<user>();

            HtmlDocument docNav = new HtmlDocument();
            docNav.LoadHtml(html);

            XPathNavigator nav = docNav.CreateNavigator();

            XPathNodeIterator i = nav.Select("//table[contains(@class, 'achievements') and contains(@class, 'real')]/tbody/tr");

            while (i.MoveNext())
            {
                user u = new user();

                XPathNavigator node = i.Current.SelectSingleNode("./td[contains(@class, 'name')]");
                if (node != null) u.account = node.Value.Trim();

                node = i.Current.SelectSingleNode("./td[contains(@class, 'achievements')]/span/span[not(contains(@class, 'additional'))]");
                if (node != null) int.TryParse(node.Value.Trim(), out u.ap);

                node = i.Current.SelectSingleNode("./td[contains(@class, 'achievements')]/span/span[contains(@class, 'additional')]");
                if (node != null) u.lastapgain = node.Value.Remove(0, node.Value.IndexOf("Since") + 5).Replace("&#x2F;", "/").Trim();

                node = i.Current.SelectSingleNode("./td[contains(@class, 'world')]");
                if (node != null) u.world = node.Value.Trim();

                list.Add(u);
            }

            return list;
        }
        public List <string> ArchiveToPosts(string tumBlogURL)
        {
            try
            {
                tumDownHttpReq = tumDownProxy.GetHttpWebRequest(tumBlogURL);
                tumDownHttpRes = (HttpWebResponse)tumDownHttpReq.GetResponse();

                Console.Write(tumDownHttpRes.StatusCode);

                tumDownSR = new StreamReader(tumDownHttpRes.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"));
                tumDoc.Load(tumDownSR);
                ResDisposed();
                HtmlNodeCollection tumArcHTMLNodes = tumDoc.DocumentNode.SelectNodes(".//a[@class]");
                Console.WriteLine("*****" + tumDoc.CreateNavigator().ToString());
                foreach (HtmlNode tmpHn in tumArcHTMLNodes)
                {
                    if (tmpHn.Attributes["class"].Value == "hover")
                    {
                        tumPostsLT.Add(tmpHn.Attributes["href"].Value);
                    }
                }
            }
            catch (WebException e)
            {
                Console.Write("错误类型" + e.Status + ",错误信息:" + e.Message + ",方法ArchiveToPost");
            }
            finally {
                ResDisposed();
            }



            return(tumPostsLT);
        }
        public NotificationView(JToken token_)
        {
            token = token_;
            InitializeComponent();
            // Getting link
            foreach (var link in token_["link"])
            {
                if ((string) link["type"] == "text/html")
                    videoUri = new Uri((string) link["href"], UriKind.RelativeOrAbsolute);
            }

            // Parsing content to get icon
            string unescaped_content = HttpUtility.HtmlDecode((string) token["content"]["$t"]);

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(unescaped_content);
            var navigator = doc.CreateNavigator();
            var node = navigator.SelectSingleNode("//td[1]//img/@src");
            imageUri = new Uri(node.Value);

            BitmapImage bitmapImage = new BitmapImage(imageUri);
            /*            Bitmap newImage = new Bitmap(64, 64);
                        using (Graphics gr = Graphics.FromImage(newImage))
                        {
                            gr.SmoothingMode = SmoothingMode.HighQuality;
                            gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
                            gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
                            gr.DrawImage(srcImage, new Rectangle(0, 0, 64, 64));
                        }
                        this.image.Source = new BitmapImage(uri);*/
            this.image.Source = bitmapImage;
            this.textBlockDescription.Text = ((string)token["author"][0]["name"]["$t"]) + " uploaded a new video: " + ((string)token["title"]["$t"]);
        }
Пример #6
0
        /// <summary>
        /// 将当前 HtmlNodeNavigator 转化为 Root HtmlNodeNavigator
        /// </summary>
        /// <param name="navigator"></param>
        /// <remarks>Hesinx 2016-05-26</remarks>
        /// <returns></returns>
        public static HtmlNodeNavigator ToRoot(this HtmlNodeNavigator navigator)
        {
            string       docHtml = navigator.CurrentNode.OuterHtml;
            HtmlDocument doc     = new HtmlDocument();

            doc.LoadHtml(docHtml);
            return(doc.CreateNavigator() as HtmlNodeNavigator);
        }
Пример #7
0
 public void Import(TextReader textReader, TextWriter textWriter)
 {
     this.textWriter = textWriter;
     var htmlDocument = new HtmlDocument();
     htmlDocument.Load(textReader);
     var navigator = htmlDocument.CreateNavigator();
     navigator.MoveToRoot();
     RecursiveWalkThroughXpath(navigator);
     textWriter.Flush();
 }
Пример #8
0
        public void IncludeItem()
        {
            var control = new XslFile();
            control.Path = "xsl/dc2011/navigation.xslt";

            Sitecore.Context.Item = Sitecore.Context.Database.GetItem("/sitecore/content/dc2011");
            var output = control.RenderAsText();

            var doc = new HtmlDocument();
            doc.LoadHtml(output);

            var nav = doc.CreateNavigator();
            var link = nav.Select("/nav[@class='primary']/ul/li[a/@href='/en/About Us.aspx']/a");

            Assert.AreEqual(1, link.Count);
        }
Пример #9
0
        //private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        //{
        //    progressBar.Value = e.ProgressPercentage;
        //}
        //private void click_Click(object sender, EventArgs e)
        //{
        //    WebClient webClient = new WebClient();
        //    webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadCompleted);
        //    webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);

        //    string sourceFile = $"http://openload.co/stream/Ki5y8-mPcoE~1558022792~95.108.0.0~mdmeUiAb?";
        //    webClient.DownloadFileAsync(new Uri(sourceFile), "test.mp4");
        //}
        //private void DownloadCompleted(object sender, AsyncCompletedEventArgs e)
        //{
        //    MessageBox.Show("The download is completed!");
        //}

        private void button1_Click(object sender, EventArgs e)
        {
            using (var client = new WebClient())
            {
                string page = adres.Text;
                string html = client.DownloadString(page);

                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(html);



                HtmlNodeNavigator navigator = (HtmlNodeNavigator)doc.CreateNavigator();
                string            xPath     = "//*[@id=\"olvideo_html5_api\"]";

                string val = navigator.SelectSingleNode(xPath).Value;
                adres.Text = val;
            }
        }
Пример #10
0
        protected void Analyse()
        {
            HtmlDocument hd = new HtmlDocument();
            hd.LoadHtml(this.HtmlContent);
            XPathNavigator xn = hd.CreateNavigator();

            while (xn.MoveToFollowing(XPathNodeType.Element))
            {
                if (xn.LocalName == "a")
                {
                    XPathNavigator xn_attr = xn.Clone();
                    if (xn_attr.MoveToAttribute("href", xn.NamespaceURI))
                    {
                        //Debug.Print("GotLink:{0}", xn_attr.Value);
                        this.Resources.Add(new Resource(new Uri(this.Url, xn_attr.Value), this));
                    }
                }
            }
        }
Пример #11
0
        public IEnumerable<Uri> ExtractLinks(Uri documentUrl, TextReader reader, string mediaType)
        {
            if (mediaType != MediaTypeNames.Text.Html && mediaType != "application/xhtml+xml")
                yield break;

            var document = new HtmlDocument();
            document.Load(reader);
            var xpath = document.CreateNavigator();

            var absoluteUriBase = documentUrl;
            var @base = (string)xpath.Evaluate("string(/html/head/base/@href)");
            if (@base.IsNotNullOrEmpty()) {
                // TODO: log this
                if (!Uri.TryCreate(@base, UriKind.Absolute, out absoluteUriBase))
                    absoluteUriBase = documentUrl;
            }

            var hrefs = xpath.Select("//a/@href").Cast<XPathNavigator>().Select(x => x.Value);
            foreach (var href in hrefs) {
                Uri uri;
                if (!Uri.TryCreate(href, UriKind.RelativeOrAbsolute, out uri)) /* broken link */ {
                    // TODO: log this
                    continue;
                }

                if (!uri.IsAbsoluteUri)
                    uri = new Uri(absoluteUriBase, uri);

                if (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps && uri.Scheme != Uri.UriSchemeFtp) {
                    // TODO: log this
                    continue;
                }

                yield return uri;
            }
        }
Пример #12
0
        private void prüfenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddTextToProtocol("Prüfe");
            if (String.IsNullOrEmpty(htmlFileName))
            {
                MessageBox.Show("Es wurde keine Datei geladen. Bitte erst HTML laden.", "Keine Datei", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            var doc = new HAP.HtmlDocument();

            try {
                doc.Load(htmlFileName);
                var nav = doc.CreateNavigator();
                AddTextToProtocol("Datei okay");
                // <img>
                var imgTags = nav.Select("//img");
                AddTextToProtocol("{0} verlinkte Bilder", imgTags.Count);
                var imgFolderCnt = Directory.GetFiles(imgFolder).Length;
                var err          = false;
                if (imgFolderCnt < imgTags.Count)
                {
                    AddTextToProtocol(" --- Ergebnis: {0} Links {1} Bilder (Bilder fehlen, bitte hochladen)", imgTags.Count,
                                      imgFolderCnt);
                    err = true;
                }
                if (imgFolderCnt > imgTags.Count)
                {
                    AddTextToProtocol(" --- Ergebnis: {0} Links {1} Bilder (Zuviele Bilder, ist aber okay)", imgTags.Count,
                                      imgFolderCnt);
                }
                if (imgFolderCnt == imgTags.Count)
                {
                    AddTextToProtocol(" --- Ergebnis: {0} Links {1} Bilder (Perfekt)", imgTags.Count,
                                      imgFolderCnt);
                }
                if (err)
                {
                }
                imgFileArrayToChange = new Dictionary <string, string>();
                var successCnt = 0;
                var missingCnt = 0;
                // Check all tags
                foreach (var imgTag in imgTags)
                {
                    var node = ((HAP.HtmlNodeNavigator)imgTag).CurrentNode;
                    if (node != null)
                    {
                        var foundImg = false;
                        var src      = node.Attributes["src"].Value;
                        if (string.IsNullOrEmpty(src))
                        {
                            continue;
                        }
                        // lookup in Img Folder
                        var attemptToFolder     = Directory.Exists(imgFolder) ? imgFolder : String.Empty;
                        var attemptToFile       = Path.GetFileName(src);
                        var lookupFullPathFiles = Directory.GetFiles(attemptToFolder, attemptToFile);
                        if (lookupFullPathFiles.Length == 0)
                        {
                            // correct HTML encoding
                            attemptToFile       = HttpUtility.UrlDecode(attemptToFile);
                            lookupFullPathFiles = Directory.GetFiles(attemptToFolder, attemptToFile);
                            if (lookupFullPathFiles.Length == 0)
                            {
                                attemptToFile       = System.Text.Encoding.Default.GetString(System.Text.Encoding.Default.GetBytes(attemptToFile));
                                lookupFullPathFiles = Directory.GetFiles(attemptToFolder, attemptToFile);
                                if (lookupFullPathFiles.Length == 0)
                                {
                                    AddTextToProtocol(" --- Bild nicht gefunden: {0}", attemptToFile);
                                    missingCnt++;
                                }
                                else
                                {
                                    foundImg = true;
                                }
                            }
                            else
                            {
                                foundImg = true;
                            }
                        }
                        else
                        {
                            foundImg = true;
                        }
                        if (foundImg)
                        {
                            successCnt++;
                            AddTextToProtocol(@"Bild gefunden, Pfad falsch ({0}\{1})", attemptToFolder, attemptToFile);
                            // add with proper name to import array
                            if (!imgFileArrayToChange.ContainsKey(src))
                            {
                                imgFileArrayToChange.Add(src, attemptToFile);
                            }
                        }
                    }
                }
                AddTextToProtocol(" --- Gesamt: {0} korrekt verlinkt, {1} korrigierbar, {2} fehlen", successCnt,
                                  imgFileArrayToChange.Count(), missingCnt);
            } catch (Exception ex) {
                AddTextToProtocol("! Fehler: " + ex.Message);
            } finally {
            }
        }
        public MonsterInitiativeTableEntry(string description, string html)
            : base(description, html)
        {
            // attempt to wade through the statblock tag soup and pull out the stats we need
            try
            {
                HtmlDocument doc;
                XPathNavigator nav;
                XPathNodeIterator iter;

                // load document and select all the bold thingies, they mark beginnings of things
                doc = new HtmlDocument();
                doc.LoadHtml(html);
                nav = doc.CreateNavigator();
                iter = nav.Select("//div[@id = 'detail']/p/b");

                // we have some chance of finding what we want here...
                while (iter.MoveNext())
                {
                    switch (iter.Current.Value.Trim().ToLowerInvariant())
                    {
                        case "initiative":
                            if (iter.Current.MoveToNext(XPathNodeType.Text))
                                this.InitiativeBonus = TolerantParse(iter.Current.Value);
                            break;
                        case "ac":
                            if (iter.Current.MoveToNext(XPathNodeType.Text))
                                this.AC = TolerantParse(iter.Current.Value);
                            break;
                        case "fortitude":
                            if (iter.Current.MoveToNext(XPathNodeType.Text))
                                this.Fortitude = TolerantParse(iter.Current.Value);
                            break;
                        case "reflex":
                            if (iter.Current.MoveToNext(XPathNodeType.Text))
                                this.Reflex = TolerantParse(iter.Current.Value);
                            break;
                        case "will":
                            if (iter.Current.MoveToNext(XPathNodeType.Text))
                                this.Will = TolerantParse(iter.Current.Value);
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                // we really ought to use a logger and track this properly
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }
Пример #14
0
    public override CommandResult Run()
    {
      if (string.IsNullOrEmpty(Input))
        return new CommandResult(CommandStatus.Failure, Constants.Messages.MissingRequiredParameter.FormatWith("input"));

      if (string.IsNullOrEmpty(XPath))
        return new CommandResult(CommandStatus.Failure, Constants.Messages.MissingRequiredParameter.FormatWith("xpath"));

      XPathNavigator nav = null;

      if (HAPRequired)
      {
        var doc = new HtmlDocument();
        try
        {
          doc.LoadHtml(Input);
        }
        catch (Exception ex)
        {
          return new CommandResult(CommandStatus.Success, "Failed to parse input: " + ex.Message);
        }

        nav = doc.CreateNavigator();
      }
      else
      {
        var doc = new XmlDocument();

        try
        {
          doc.LoadXml(Input);
        }
        catch (Exception ex)
        {
          return new CommandResult(CommandStatus.Success, "Failed to parse input: " + ex.Message);
        }

        nav = doc.CreateNavigator();
      }

      if (nav == null)
        return new CommandResult(CommandStatus.Failure, "Failed to create XPath navigator");

      // Process XML and extract any namespaces it contains. Allows using the namespaces in queries
      var namespaceManager = new XmlNamespaceManager(nav.NameTable);

      var allNodes = nav.Select("//*");
      while (allNodes.MoveNext())
      {
        var namespaces = allNodes.Current.GetNamespacesInScope(XmlNamespaceScope.Local);
        foreach (var ns in namespaces)
        {
          namespaceManager.AddNamespace(ns.Key, ns.Value);
        }
      }

      var nodes = nav.Select(XPath, namespaceManager);

      var lines = new List<string>();
      while (nodes.MoveNext())
      {
        if (ValueOutput)
          lines.Add(nodes.Current.Value);
        else
          lines.Add(nodes.Current.OuterXml);
      }

      var buffer = new StringBuilder(Formatter.JoinLines(lines));

      if (!NoStats)
      {
        Formatter.PrintLine(string.Empty, buffer);
        buffer.Append(string.Format("Matched {0} {1}", nodes.Count, (nodes.Count == 1 ? "node" : "nodes")));
      }

      return new CommandResult(CommandStatus.Success, buffer.ToString());
    }
Пример #15
0
 public void usage(HtmlDocument html)
 {
     Assert.True(html.CreateNavigator().Evaluate<bool>("1 = count(//title[text()='Example'])"));
 }
Пример #16
0
        private void scrapeSyllabusPlus(String url, int weekNumber)
        {
            String webPage = getWebpage(url);
            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(webPage);

            // get an XPath navigator so we can browse the document:
            XPathNavigator nav = doc.CreateNavigator();
            // the second table is the one we care about:
            XPathNodeIterator it = nav.Select("/html/body/table[2]");
            it.MoveNext();

            XPathNavigator rootTbl = it.Current;
            XPathNodeIterator rows = rootTbl.Select("tr");
            bool firstRow = true;
            List<String> times = new List<String>();
            String day = "";

            foreach (XPathNavigator row in rows)
            {
                XPathNodeIterator cols = row.Select("td");

                int currentCell = 0;
                bool firstCol = true;
                foreach (XPathNavigator col in cols)
                {
                    // first row contains times. It would be nice if the first row was tagged with a CSS ID, but there you go..
                    if (firstRow)
                    {
                        times.Add(col.ToString());
                    }
                    else
                    {
                        // if the current cell has CSS class "row-label-one" then skip it - it's the day of week header
                        // although we may want to keep this so we know the date? nah...
                        if (firstCol)
                        {
                            firstCol = false;
                            day = col.ToString();
                            ++currentCell;
                            continue;
                        }
                        // if the current cell has CSS class "object-cell-border then this is an appointment that needs to be
                        // synced!
                        if (col.Select("table").Count > 0)
                        //if (col.GetAttribute("class", "") == "object-cell-border")
                        {
                            // this is an event we need to sync:
                            // start time is the current cell lication:
                            String startTime = times.ElementAt(currentCell);
                            // end time is the current cell location plus colspan attribute:
                            int colspan = Int32.Parse(col.GetAttribute("colspan", ""));
                            String endTime = times.ElementAt(currentCell + colspan);

                            // there are three embedded <table> elements.
                            // the first one has the generic subject, like "Bachelor of Information Technology".
                            String department = getStringFromXSLTPath(col, "table[1]/tr/td");
                            // the second has the specific subject and type, like "Web Fundamentals", "Lecture"
                            String subject = getStringFromXSLTPath(col, "table[2]/tr/td[1]");
                            String subjType = getStringFromXSLTPath(col, "table[2]/tr/td[2]");
                            // the third has the weeks and room info.
                            String room = getStringFromXSLTPath(col, "table[3]/tr/td[2]");

                            // work out the date we're on. We know the week we're in, and we can get the week day number easily enough...
                            DateTime startDT = getDateTimeFromDayAndWeek(day, weekNumber, startTime);
                            DateTime endDT = getDateTimeFromDayAndWeek(day, weekNumber, endTime);

                            createCalendarEvent(startDT, endDT, department, subject, subjType, room);

                            // finished processing, so add the current colspan to the current cell number:
                            currentCell += colspan;
                        }
                        else
                        {
                            ++currentCell;
                        }
                    }
                }
                // completed at least one row:
                firstRow = false;
            }
        }
Пример #17
0
		private void ParseSubHTMLDoc(String SubLinkAdress)
			{
			System.Net.WebClient WClient = new System.Net.WebClient();
			Byte[] Raw = WClient.DownloadData(String.Format(EntryWebAddressTemplate, SubLinkAdress));
			String WebContent = System.Text.Encoding.UTF8.GetString(Raw);
			HtmlDocument HtmlDoc = new HtmlDocument();
			TextReader Reader = new StringReader(SkipKnownProblemStrings(WebContent));
			HtmlDoc.Load(Reader);
			HtmlDoc.OptionAddDebuggingAttributes = true;
			XPathNavigator Nav = HtmlDoc.CreateNavigator();
			XPathNodeIterator contentHeadPaneOpen = Nav.Select("//div[@class=\'page-header\']/h2[@itemprop=\'name\']");
			contentHeadPaneOpen.MoveNext();
			String HeadLine = contentHeadPaneOpen.Current.Value.Trim();
			if (String.IsNullOrEmpty(HeadLine))
				return;
			AlpenVereinPlainTextDataEntry ActuallEntry = new AlpenVereinPlainTextDataEntry() { Parent = this };
			AlpenVereinPlainTextDataEntries.Add(ActuallEntry);
			ActuallEntry.EntryHeadLine.Add(HeadLine);
			XPathNodeIterator ContentContentPaneOpen = Nav.Select("//div[@itemprop=\'articleBody\']");
			ContentContentPaneOpen.MoveNext();
			String Value = Basics.ConvertEscapedHTMLToString(ContentContentPaneOpen
				.Current.Value.Replace("____NewLine____", "^")).Trim();
			List<String> LinesToAdd = new List<string>();
			foreach (String Line in Value.Split('^'))
				if ((!String.IsNullOrEmpty(Line))
					&& (Line.Trim() != ""))
					LinesToAdd.Add(Line);
			ActuallEntry.EntryContent.AddRange(LinesToAdd);

			}
Пример #18
0
		private int ParseHtmlDoc (HtmlDocument HtmlDoc)
			{
			int NumberOfEntries = 0;
			XPathNavigator Nav = HtmlDoc.CreateNavigator ();
			XPathNodeIterator ContentPaneOpen = Nav.Select ("//div[@class=\'items-leading clearfix\']/div");
			XPathNavigator HeadlineNavigator = ContentPaneOpen.Current;
			XPathNodeIterator HeadlineIterator = HeadlineNavigator.Select("div[@itemprop=\'blogPost\']");
			//			Console.WriteLine ("---------------------------------------------------------------");

			while (ContentPaneOpen.MoveNext ())
				{
				NumberOfEntries++;
				XPathNodeIterator InnerContentIterator = ContentPaneOpen.Current.Select("div/h2[@itemprop=\'name\']/a");
				InnerContentIterator.MoveNext();
				ParseSubHTMLDoc(InnerContentIterator.Current.GetAttribute("href", ""));
				//ActuallEntry.EntryContent.Add(InnerContentIterator.Current.Value.Trim());

				//continue;
				//ContentPaneOpen.MoveNext ();
				//XPathNodeIterator ContentIterator = ContentPaneOpen.Current.Select("tr/td[@valign=\'top\']");
				//while (ContentIterator.MoveNext())
				//	{
				//	int ContentCounter = 0;
				//	String Value = Basics.ConvertEscapedHTMLToString (ContentIterator.Current.Value.Replace("____NewLine____", "^")).Trim ();
				//	List<String> LinesToAdd = new List<string> ();
				//	foreach (String Line in Value.Split('^'))
				//		if ((!String.IsNullOrEmpty (Line))
				//			&& (Line.Trim() != ""))
				//			LinesToAdd.Add(Line);
				//	ActuallEntry.EntryContent.AddRange(LinesToAdd);

				//	}
				////String ID = ActuallEntry.InformationenNameID;

				}

			return NumberOfEntries;
			}
Пример #19
0
        public void usage(HtmlDocument html)
        {
            var expected = new FileInfo("example.html").ReadToEnd();
            var actual = html.CreateNavigator().OuterXml;

            Assert.Equal(expected, actual);
        }
Пример #20
0
        public override IEnumerable<object[]> GetData(MethodInfo methodUnderTest,
                                                      Type[] parameterTypes)
        {
            if (null == methodUnderTest)
            {
                throw new ArgumentNullException("methodUnderTest");
            }

            if (null == parameterTypes)
            {
                throw new ArgumentNullException("parameterTypes");
            }

#if NET20
            if (IEnumerableExtensionMethods.Count(Files) != parameterTypes.Length)
            {
                throw new InvalidOperationException(StringExtensionMethods.FormatWith(Resources.Attribute_CountsDiffer, IEnumerableExtensionMethods.Count(Files), parameterTypes.Length));
            }
#else
            if (Files.Count() != parameterTypes.Length)
            {
                throw new InvalidOperationException(Resources.Attribute_CountsDiffer.FormatWith(Files.Count(), parameterTypes.Length));
            }
#endif

            var list = new List<object>();
            var index = -1;
            foreach (var file in Files)
            {
                var info = new FileInfo(file);
                index++;
                if (parameterTypes[index] == typeof(HtmlDocument) || parameterTypes[index] == typeof(IXPathNavigable))
                {
                    var html = new HtmlDocument();
                    html.Load(info.FullName);

                    list.Add(html);
                    continue;
                }

                if (parameterTypes[index] == typeof(XPathNavigator))
                {
                    var html = new HtmlDocument();
                    html.Load(info.FullName);

                    list.Add(html.CreateNavigator());
                    continue;
                }

                if (parameterTypes[index] == typeof(DataSet))
                {
                    var html = new HtmlDocument();
                    html.Load(info.FullName);
#if NET20
                    list.Add(HtmlDocumentExtensionMethods.TabularData(html));
#else
                    list.Add(html.TabularData());
#endif
                    continue;
                }

                throw new InvalidOperationException(Resources.HtmlAttribute_UnsupportedParameterType);
            }

            yield return list.ToArray();
        }