• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# HtmlAgilityPack.HtmlDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中HtmlAgilityPack.HtmlDocument的典型用法代码示例。如果您正苦于以下问题:C# HtmlAgilityPack.HtmlDocument类的具体用法?C# HtmlAgilityPack.HtmlDocument怎么用?C# HtmlAgilityPack.HtmlDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HtmlAgilityPack.HtmlDocument类属于命名空间,在下文中一共展示了HtmlAgilityPack.HtmlDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Grab

 List<Show> Grab(GrabParametersBase p, ILogger logger)
 {
     var pp = (GrabParameters)p;
     var url = string.Format(URL, pp.Channel.ToString().Replace("_", "-").Replace("AANNDD", "%26").Replace("PPLLUUSS", "%2B"));
     var wr = WebRequest.Create(url);
     var res = (HttpWebResponse)wr.GetResponse();
     var doc = new HtmlAgilityPack.HtmlDocument();
     logger.WriteEntry(string.Format("Grabbing Channel {0}", pp.Channel), LogType.Info);
     doc.Load(res.GetResponseStream());
     var shows = new List<Show>();
     foreach (Day d in Enum.GetValues(typeof(Day)))
     {
         var dayOfWeek = (DayOfWeek)d;
         var div = doc.DocumentNode.Descendants("div").FirstOrDefault(x => x.Attributes.Contains("id") && x.Attributes["id"].Value == d.ToString());
         if (div != null)
         {
             var date = NextDateOfDayOfWeek(dayOfWeek);
             foreach (var ul in div.Descendants("ul"))
             {
                 foreach (var li in ul.Descendants("li"))
                 {
                     var par = li.Descendants("p").First();
                     var a = li.Descendants("a").First();
                     var show = new Show();
                     show.Channel = pp.Channel.ToString();
                     show.Title = a.InnerText.Trim();
                     show.StartTime = DateTime.SpecifyKind(date + Convert.ToDateTime(par.InnerText.Trim()).TimeOfDay, DateTimeKind.Unspecified);
                     show.StartTime = TimeZoneInfo.ConvertTime(show.StartTime, TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time"), TimeZoneInfo.Utc);
                     shows.Add(show);
                 }
             }
         }
     }
     return shows;
 }
开发者ID:hagaygo,项目名称:XmlTvGenerator,代码行数:35,代码来源:WebSiteGrabber.cs


示例2: DiscoverDynamicCategories

        public override int DiscoverDynamicCategories()
        {
            int dynamicCategoriesCount = 0;
            String baseWebData = GetWebData(PrimaUtil.categoriesUrl, forceUTF8: true);

            HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
            document.LoadHtml(baseWebData);

            HtmlAgilityPack.HtmlNodeCollection categories = document.DocumentNode.SelectNodes(".//div[@class='programs-menu-genres']/*/a");

            foreach (var category in categories)
            {
                this.Settings.Categories.Add(
                    new RssLink()
                    {
                        Name = category.InnerText,
                        HasSubCategories = true,
                        Url = Utils.FormatAbsoluteUrl(category.Attributes["href"].Value, PrimaUtil.categoriesUrl)
                    });

                dynamicCategoriesCount++;
            }

            this.Settings.DynamicCategoriesDiscovered = true;
            return dynamicCategoriesCount;
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:26,代码来源:PrimaUtil.cs


示例3: NewsGoVnGroup_Parse

        public static async Task<DataGroup> NewsGoVnGroup_Parse(string xmlString, DataModel.DataGroup group, int takeNum)
        {
            StringReader _stringReader = new StringReader(xmlString);
            XDocument _xdoc = XDocument.Load(_stringReader);
            var channelElement = _xdoc.Element("rss").Element("channel");
            if (channelElement != null)
            {
                group.Title = channelElement.Element("title").Value;
                group.Subtitle = channelElement.Element("title").Value;
                group.Description = channelElement.Element("description").Value;

                var items = channelElement.Elements("item");
                foreach (var item in items)
                {
                    if (group.Items.Count == takeNum && takeNum >= 0) break;

                    DataItem dataItem = new DataItem();
                    dataItem.Title = item.Element("title").Value;
                    dataItem.Description = StripHTML(item.Element("description").Value);
                    dataItem.Link = new Uri(item.Element("link").Value, UriKind.Absolute);
                    dataItem.PubDate = item.Element("pubDate").Value;

                    HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
                    htmlDoc.Load(new StringReader(item.Element("description").Value));

                    HtmlAgilityPack.HtmlNode imageLink = getFirstNode("img", htmlDoc.DocumentNode);
                    dataItem.ImageUri = new Uri(imageLink.GetAttributeValue("src", string.Empty).Replace("96.62.jpg", "240.155.jpg"), UriKind.Absolute);

                    dataItem.Group = group;
                    group.Items.Add(dataItem);
                }
            }

            return group;
        }
开发者ID:nhannguyen2204,项目名称:VnFeeds_Win8,代码行数:35,代码来源:ParseDocHelper.cs


示例4: mshtmlDocToAgilityPackDoc

 /// <summary>
 /// Converts onlyconnect.IHTMLDocument2 class to HtmlAgilityPack.HtmlDocument
 /// </summary>
 /// <param name="doc">IHTMLDocument2 document</param>
 /// <returns>Converted HtmlDocument</returns>
 public static HtmlAgilityPack.HtmlDocument mshtmlDocToAgilityPackDoc(onlyconnect.IHTMLDocument2 doc)
 {
     HtmlAgilityPack.HtmlDocument outDoc = new HtmlAgilityPack.HtmlDocument();
     string html = doc.GetBody().innerHTML;
     outDoc.LoadHtml(html);
     return outDoc;
 }
开发者ID:artmachinez,项目名称:bc,代码行数:12,代码来源:HTMLDocumentConverter.cs


示例5: LoadHtml

        private static HtmlAgilityPack.HtmlDocument LoadHtml()
        {
            var doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(Resource.GetString("Test1.html"));

            return doc;
        }
开发者ID:ccwalkerjm,项目名称:HtmlAgilityPack.CssSelector,代码行数:7,代码来源:Test1.cs


示例6: Get

        public ProgramOptions Get(string configPath)
        {
            var html = new HtmlAgilityPack.HtmlDocument();
            html.Load(configPath);

            var options = new ProgramOptions();
            options.BlogUrl = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/blogurl", "", true);
            options.BlogUser = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/bloguser", "", true);
            options.BlogPassword = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/blogpassword", "", true);
            options.DatabaseUrl = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/databaseurl", "", true);
            options.DatabaseName = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/databasename", "", true);
            options.DatabaseUser = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/databaseuser", "", true);
            options.DatabasePassword = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/databasepassword", "", true);

            options.FtpUrl = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/ftpurl", "", true);
            options.FtpUser = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/ftpuser", "", true);
            options.FtpPassword = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/ftppassword", "", true);

            options.ProxyAddress = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/proxyaddress", "", true);
            options.ProxyPort = XmlParse.GetIntegerNodeValue(html.DocumentNode, "/programoptions/proxyport", 0);
            options.UseProxy = XmlParse.GetBooleanNodeValue(html.DocumentNode, "/programoptions/useproxy", false);

            options.YoutubeClient = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/youtubeclient", "", true);
            options.YoutubeClientSecret = XmlParse.GetStringNodeValue(html.DocumentNode, "/programoptions/youtubeclientsecret", "", true);

            return options;
        }
开发者ID:yukseljunk,项目名称:wps,代码行数:27,代码来源:ProgramOptionsFactory.cs


示例7: FetchRates

        public static void FetchRates(int bankId, string bankName)
        {
            var bankExchange = new BankExchange();
            bankExchange.BankId = bankId;

            if (bankName.ToLowerInvariant() == "bank asya")
            {
                var ds = new DataSet("fxPrices");
                ds.ReadXml("http://www.bankasya.com.tr/xml/kur_list.xml");

                bankExchange.USDBuying = Int32.Parse(ds.Tables[1].Rows[0]["Kur"].ToString().Replace(".", ""));
                bankExchange.USDSelling = Int32.Parse(ds.Tables[1].Rows[1]["Kur"].ToString().Replace(".", ""));
                bankExchange.EURBuying = Int32.Parse(ds.Tables[1].Rows[2]["Kur"].ToString().Replace(".", ""));
                bankExchange.EURSelling = Int32.Parse(ds.Tables[1].Rows[3]["Kur"].ToString().Replace(".", ""));

                bankExchange.Save();
            }
            else if(bankName.ToLowerInvariant() == "finansbank")
            {
                var doc = new HtmlAgilityPack.HtmlDocument();
                doc.Load("http://www.finansbank.com.tr/bankacilik/alternatif-dagitim-kanallari/internet-bankaciligi/doviz_kurlari.aspx?IntSbMO_FB_Mevduatoranlari_PU".DownloadPage());

            }
            else
            {
                throw new Exception("Banka adı bunlardan biri olabilir: Bank Asya");
            }
        }
开发者ID:fizikci,项目名称:Cinar,代码行数:28,代码来源:BankExchange.cs


示例8: FillDbFromSite

        public static void FillDbFromSite()
        {
            // Add Currency
            banks.Сurrency.Add(new Сurrency() { Name = "USD" });
            banks.Сurrency.Add(new Сurrency() { Name = "EUR" });
            banks.Сurrency.Add(new Сurrency() { Name = "RUB" });
            banks.Сurrency.Add(new Сurrency() { Name = "EUR -> USD" });

            //Add Banks
            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            WebClient wc = new WebClient();
            wc.Encoding = Encoding.UTF8;
            doc.LoadHtml(wc.DownloadString("http://myfin.by/currency/minsk"));

            foreach (HtmlAgilityPack.HtmlNode tablet in doc.DocumentNode.SelectNodes("//*[@id='workarea']/div[3]/div[3]/div/table/tbody/tr[1]"))
            {
                foreach (HtmlAgilityPack.HtmlNode row in tablet.SelectNodes("td[1]"))
                {
                    banks.Bank.Add(new Bank() { Name = row.InnerText });
                }
            }

            
            //banks.Department.Add(new Department() { });

            //banks.DeprtmentsСurrencies.Add(new Department());


            banks.SaveChanges();
        }
开发者ID:irinalesina,项目名称:ITStepProjects,代码行数:30,代码来源:BanksSystemAPI.cs


示例9: Convert

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // 例えば ConverterParameter=true とすると、parameter に string "true" が入ります。
            if (value == null)
                return "";

            // HtmlAgilityPack を使用してタグ付きの string からタグを除去します。
            var hap = new HtmlAgilityPack.HtmlDocument();
            hap.LoadHtml(value.ToString());
            var doc = hap.DocumentNode.InnerText;
            doc = doc.Replace(@"&nbsp;", " ").Replace(@"&lt;", "<").Replace(@"&gt;", ">").Replace(@"&amp;", "&").Replace(@"&quot;", "\"");

            var multiCRRegex = new Regex(@"\n\n\n+");
            doc = multiCRRegex.Replace(doc, "\n\n");

            // parameter には数字が入りますので、数値があればその文字数でカットした string を返します。
            int strLength;
            if (int.TryParse(parameter as string, out strLength)) {
                if (doc.Length > strLength)
                {
                    return doc.Substring(0, strLength) + "…";
                }
                return doc;
            }
            else
            {
                return doc;
            }
        }
开发者ID:ytabuchi,项目名称:ITStudySearch,代码行数:29,代码来源:HtmlToPlainConverter.cs


示例10: LoadContent

        private async Task LoadContent(DataItem _item)
        {
            string contentStr = string.Empty;
            try
            {
                contentStr = await Define.DownloadStringAsync(_item.Link);
            }
            catch (Exception ex)
            {

                //throw;
            }

            if (contentStr != string.Empty)
            {
                HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
                htmlDoc.LoadHtml(contentStr);

                HtmlAgilityPack.HtmlNode htmlNode = htmlDoc.GetElementbyId("ContentContainer");
                while (htmlNode.Descendants("script").Count() > 0)
                {
                    htmlNode.Descendants("script").ElementAt(0).Remove();
                }
                while (htmlNode.Descendants("meta").Count() > 0)
                {
                    htmlNode.Descendants("meta").ElementAt(0).Remove();
                }

                //contentStr = "<p><i>This blog post was authored by Andrew Byrne (<a href=\"http://twitter.com/AndrewJByrne\" target=\"_blank\">@AndrewJByrne</a>), a Senior Content Developer on the Windows Phone Developer Content team.</i> <p><i></i> <p><i>- Adam</i></p> <hr>  <p> <table cellspacing=\"1\" cellpadding=\"2\" width=\"722\" border=\"0\"> <tbody> <tr> <td valign=\"top\" width=\"397\"> <p>The Windows Phone Developer Content team is continually adding new code samples that you can download from MSDN. In this post, we introduce you to the 10 latest samples that we’ve posted on MSDN. Each sample includes a readme file that walks you through building and running the sample, and includes links to relevant, related documentation. We hope these samples help you with your app development and we look forward to providing more samples as we move forward. You can check out all of our <a href=\"http://code.msdn.microsoft.com/wpapps/site/search?f%5B0%5D.Type=Contributors&amp;f%5B0%5D.Value=Windows%20Phone%20SDK%20Team&amp;f%5B0%5D.Text=Windows%20Phone%20SDK&amp;sortBy=Date\" target=\"_blank\">samples on MSDN</a>.</p></td> <td valign=\"top\" width=\"320\"> <p><a href=\"http://blogs.windows.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-53-84-metablogapi/clip_5F00_image002_5F00_1765A66A.png\"><img title=\"clip_image002\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto\" border=\"0\" alt=\"clip_image002\" src=\"http://blogs.windows.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-53-84-metablogapi/clip_5F00_image002_5F00_thumb_5F00_7B083E7C.png\" width=\"121\" height=\"213\"></a></p></td></tr></tbody></table></p> <h3><a href=\"http://go.microsoft.com/fwlink/?LinkId=306704\" target=\"_blank\">Stored Contacts Sample</a></h3> <p>This sample illustrates how to use the <a href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.phone.personalinformation.contactstore(v=vs.105).aspx\" target=\"_blank\">ContactStore</a> class and related APIs to create a contact store for your app. This feature is useful if your app uses an existing cloud-based contact store. You can use the APIs you to create contacts on the phone that represent the contacts in your remote store. You can display and modify the contacts in the People Hub on your phone, just like contacts that are added through the built-in experience. You can use the APIs to update and delete contacts you have created on the phone and also to query for any changes the user has made to the contacts locally so you can sync those changes to your remote store. <h3><a href=\"http://go.microsoft.com/fwlink/?LinkId=306701\" target=\"_blank\">Basic Storage Recipes</a></h3> <p>This is a “Windows Runtime Storage 101” sample for Windows Phone developers moving from isolated storage and <b>System.IO</b> to <a href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.storage.aspx\" target=\"_blank\">Windows.Storage</a> and <a href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.storage.streams.aspx\" target=\"_blank\">Windows.Storage.Streams</a>. The sample demonstrates how to write to and read files, in addition to how to enumerate directory trees. It also demonstrates how to pass data from one page to the next, and how to persist application state when the app is deactivated. <h3><a href=\"http://go.microsoft.com/fwlink/?LinkId=301509\" target=\"_blank\">Trial Experience Sample</a></h3> <p>This sample shows you how to design your app to detect its license state when the app launches, and how to detect changes to the license state while running. It comes with a helper class that you can use in your app to wrap <a href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.applicationmodel.store.licenseinformation.aspx\" target=\"_blank\">LicenseInformation</a> functionality. <h3><a href=\"http://go.microsoft.com/fwlink/?LinkId=302059\" target=\"_blank\">Windows Runtime Component Sample</a></h3> <p>This sample demonstrates the basics of creating a Windows Phone Runtime component in C++ and consuming it in a XAML app. The sample demonstrates three scenarios: the first scenario illustrates how to call synchronous and asynchronous methods to perform a computation. The second scenario uses the same computation component to demonstrate progress reporting and cancellation of long-running tasks. Finally, the third scenario shows how to use a component to wrap logic that uses <a href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206944(v=vs.105).aspx\" target=\"_blank\">XAudio2 APIs</a> to play a sound. <h3><a href=\"http://go.microsoft.com/fwlink/?LinkId=306097\" target=\"_blank\">Company Hub Sample</a></h3> <p>This sample demonstrates the construction of an app that is capable of deploying line-of-business (LOB) apps to employees of a corporation. The sample uses an example XML file to define the company XAPs that are available to employees for secure download, and shows you how to dynamically access that file at run time. Then it shows you how to install company apps, enumerate the apps, and then launch the installed company apps. This app is just an example framework and requires additional work beyond the sample to be functional. <h3><a href=\"http://go.microsoft.com/fwlink/?LinkId=306702\" target=\"_blank\">Image Recipes</a></h3> <p>This sample illustrates how to use images in your app efficiently, while giving your users a great experience. It tackles downsampling images, implementing pinch and zoom, and downloading images with a progress display and an option to cancel the download. We’ve taken a recipe approach: each recipe is delivered in a self-contained page in the app so you can focus your attention on the particular part of the sample you are most interested in.  <h3><a href=\"http://go.microsoft.com/fwlink/?LinkId=306026\" target=\"_blank\">Azure Voice Notes</a></h3> <p>This sample uses Windows Phone speech recognition APIs and Windows Azure Mobile Services to record voice notes as text and store the notes in the cloud. It shows how Mobile Services can be used to authenticate a user with their Microsoft Account. It also demonstrates how to use Mobile Services to store, retrieve, and delete data from an Azure database table. The app generates text from speech using the Windows Phone speech recognition APIs and the phone’s predefined dictation grammar. <h3><a href=\"http://go.microsoft.com/fwlink/?LinkId=299241\" target=\"_blank\">Kid's Corner Sample</a></h3> <p>This sample illustrates how to use the <a href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.phone.applicationmodel.applicationprofile.modes(v=vs.105).aspx\" target=\"_blank\">ApplicationProfile.Modes</a> property to recognize Kid’s Corner mode. When the app runs, it checks the <a href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.phone.applicationmodel.applicationprofile.modes(v=vs.105).aspx\" target=\"_blank\">ApplicationProfile.Modes</a> property. If the value is <b>ApplicationProfileModes.Alternate</b>, you’ll know that the app is running in Kid’s Corner mode. Depending on the content of your app, you may want to change its appearance or features when it runs in Kid’s Corner mode. Some features that you should consider disabling when running in Kid’s Corner mode include in-app purchases, launching the web browser, and the ad control. <h3><a href=\"http://go.microsoft.com/fwlink/?LinkId=267468\" target=\"_blank\">URI Association Sample</a></h3> <p>Use this sample to learn how to automatically launch your app via URI association. This sample includes three apps: a URI launcher, and two apps that handle the URI schemes that are built in to the launcher app. You can launch an app that is included with the sample or edit the URI and launch a different app. There is also a button for launching a URI on another phone using Near Field Communication (NFC).  <h3><a href=\"http://go.microsoft.com/fwlink/?LinkId=275007\" target=\"_blank\">Speech for Windows Phone: Speech recognition using a custom grammar</a></h3> <p>A grammar defines the words and phrases that an app will recognize in speech input. This sample shows you how to go beyond the basics to create a powerful grammar (based on the grammar schema) with which your app can recognize commands and phrases constructed in different ways. <p>&nbsp; <p>This post is just a glimpse of the latest Windows Phone samples we’ve added to the MSDN code gallery. From launching apps with URI associations, to dictating notes and storing them in the cloud, we hope that there’s something for everyone. We’ll be sure to keep you posted as new samples are added to the collection, so stay tuned. In the meantime, grab the samples, experiment with them, and use the code to light up your apps. You can download all Windows Phone samples at <a href=\"http://code.msdn.microsoft.com/wpapps\" target=\"_blank\">http://code.msdn.microsoft.com/wpapps</a>. <div style=\"clear:both;\"></div><img src=\"http://blogs.windows.com/aggbug.aspx?PostID=588575&AppID=5384&AppType=Weblog&ContentType=0\" width=\"1\" height=\"1\">";
                Items[Items.IndexOf(_item)].Content = htmlNode.InnerHtml.Replace("\r", "").Replace("\n", "");
            }
        }
开发者ID:nhannguyen2204,项目名称:VnFeeds_Win8,代码行数:32,代码来源:ItemDetailViewModel.cs


示例11: DoLogin

        public CookieContainer DoLogin()
        {
            const string formUrl = "http://dbunet.dbu.dk";
            var req = (HttpWebRequest)WebRequest.Create(formUrl);
            req.Method = "GET";

            var resp = req.GetResponse() as HttpWebResponse;
            var loginPage = new HtmlDocument();
            loginPage.Load(resp.GetResponseStream());
            
            var viewstate = loginPage.DocumentNode.SelectSingleNode("//input[@name='__VIEWSTATE']").GetAttributeValue("value","---");

            string proxy = null;
            
            var formParams = string.Format("?__VIEWSTATE={0}&_ctl2:sys_txtUsername={1}&_ctl2:sys_txtPassword={2}&_ctl2:cbRememberMe=true&_ctl2:ibtnSignin=Continue&_ctl2:ibtnSignin.x=33&_ctl2:ibtnSignin.y=3&TopMenu_ClientState=", viewstate, UserName, Password);
            req = (HttpWebRequest)WebRequest.Create(formUrl);
            req.ContentType = "application/x-www-form-urlencoded";
            req.Method = "POST";
            req.KeepAlive = true;
            req.AllowAutoRedirect = false;
            req.Proxy = new WebProxy(proxy, true); // ignore for local addresses
            req.CookieContainer = new CookieContainer(); // enable cookies
            byte[] bytes = Encoding.ASCII.GetBytes(formParams);
            req.ContentLength = bytes.Length;
            using (var os = req.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
            }
            resp = (HttpWebResponse)req.GetResponse();

            return req.CookieContainer;
        }
开发者ID:woodbase,项目名称:Woodbase.RefereeToolkit,代码行数:32,代码来源:Login.cs


示例12: ExtractFilmTitleUsingXPath

		internal static string ExtractFilmTitleUsingXPath(string html)
		{


			//TODO: Currently the film's Original Title is used as the default Title. If no Original Title is available, we should get the film's default title.

			var doc = new HtmlDocument();

			doc.LoadHtml(html);

			HtmlAgilityPack.HtmlNode htmlNode
				= doc.DocumentNode.SelectSingleNode
					(@"//span[@class='title-extra']");

		    string originalTitle = htmlNode.InnerText;


			////TODO: The xml data should be loaded and received from memory instead of a file.

			

			originalTitle = RegExDataMiners.MatchRegexExpressionReturnFirstMatchFirstGroup
				(originalTitle, "\"(?<Title>.*?)\"");


			//MessageBox.Show(originalTitle);

			return (originalTitle);


		}
开发者ID:stavrossk,项目名称:MeediFier_for_MeediOS,代码行数:31,代码来源:XPathDataMiners.cs


示例13: HtmlDocument

        internal static string[] MatchXpathExpressionReturnAllMatches
            (string html, string xPathExpression)
        {


            var doc = new HtmlDocument();

            doc.LoadHtml(html);

            HtmlAgilityPack.HtmlNodeCollection htmlNodesCollection
                = doc.DocumentNode.SelectNodes
                    (xPathExpression);

            var matches = new List<string>();

            foreach (var htmlNode in htmlNodesCollection)
            {
                matches.Add(htmlNode.InnerText);

            }





            return matches.ToArray();

        }
开发者ID:stavrossk,项目名称:MeediFier_for_MeediOS,代码行数:28,代码来源:XPathDataMiners.cs


示例14: GetContent

        private AmazonProduct GetContent(String ASin)
        {
            var content = "";

            var client = new WebClient();

            var headers = new WebHeaderCollection();

            headers.Add(HttpRequestHeader.Accept, "text/html, application/xhtml+xml, */*");
            //headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
            headers.Add(HttpRequestHeader.AcceptLanguage, "en-GB");
            headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko");

            client.Headers = headers;

            var rawhtml = client.DownloadString("http://www.amazon.co.uk/dp/"+ ASin);

            HtmlAgilityPack.HtmlDocument Html = new HtmlAgilityPack.HtmlDocument();

            Html.LoadHtml(rawhtml);

            var title = GetTitle(Html);

            var description = GetDescription(Html);

            AmazonProduct prod = new AmazonProduct() { Description = description, Title = title };

            return prod;
        }
开发者ID:Neil19533,项目名称:AParser,代码行数:29,代码来源:AZonController.cs


示例15: GetNCTSongs

        public XmlNodeList GetNCTSongs(string html)
        {
            XmlDocument songDoc = new XmlDocument();
            try
            {
                HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
                htmlDoc.LoadHtml(html);
                //http://www.nhaccuatui.com/flash/xml?html5=true&key2=469177aa57117104d2e3d1ea0da2b3bc
                string pattern = @"http:\/\/www\.nhaccuatui.com\/flash\/xml\?(html5=true&)?key(2|1)=.*";
                Match match = Regex.Match(html, pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                string xmlURL = "";
                if (match.Success)
                {
                    xmlURL = match.Value;
                }
                int objIndex = xmlURL.IndexOf("\"");
                xmlURL = xmlURL.Substring(0, objIndex);
                AlbumName = htmlDoc.DocumentNode.SelectSingleNode("//h1[@itemprop='name']").InnerText;
                objHTML.URL = xmlURL;

                string songXML = objHTML.GetHTMLString();

                songDoc.LoadXml(songXML);
            }
            catch (Exception ex)
            {

                throw ex;
            }
            return songDoc.SelectNodes("//track");
        }
开发者ID:jkiller295,项目名称:Get-link-NCT,代码行数:31,代码来源:NCT.cs


示例16: GetSchool

            /// <summary>
            /// Gets school info: name and departments name from html polish Wikipedia page.
            /// </summary>
            /// <param name="filePath">Path to locally saved html file.</param>
            /// <returns>School object with name and list of departments name.</returns>
            public static School GetSchool(string filePath)
            {
                HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

                htmlDoc.OptionFixNestedTags = true;
                var e = htmlDoc.Encoding;
                htmlDoc.Load(filePath, Encoding.UTF8);

                var school = new School();

                if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
                {
                    // Handle any parse errors as required
                }
                else
                {

                    if (htmlDoc.DocumentNode != null)
                    {
                        var nodes = htmlDoc.DocumentNode.Descendants();
                        school.Name = nodes.First(x => x.Id == "firstHeading").InnerText;
                        var content = nodes.First(x => x.Id == "mw-content-text").Descendants().Where(x=>x.Name=="li").ToList();

                        foreach (var item in content)
                        {
                            if(item.InnerText.Contains("Wydział")) {
                                school.Departments.Add(item.InnerText);
                            }
                        }
                    }
                }

                return school;
            }
开发者ID:ignacy130,项目名称:WikipediaExtractor,代码行数:39,代码来源:Program.cs


示例17: GetChannelList

 private static void GetChannelList(string webHtml)
 {
     var doc = new HtmlAgilityPack.HtmlDocument();
     doc.LoadHtml(webHtml);
     var aList = doc.DocumentNode.Descendants("a")
         .Where(u =>
         (!string.IsNullOrEmpty(u.GetAttributeValue("href", "")) &&
         u.GetAttributeValue("class", "").Equals("btn btn-block btn-primary"))
         || (string.IsNullOrEmpty(u.GetAttributeValue("href", "")) && string.IsNullOrEmpty(u.GetAttributeValue("class", "")))
         ).ToArray();
     var length = aList.Count(u => string.IsNullOrEmpty(u.GetAttributeValue("href", "")));
     var clModels = new ChannelListJsonModel[length];
     var i = -1;
     foreach (var a in aList)
     {
         if (string.IsNullOrEmpty(a.GetAttributeValue("href", "")))
         {
             clModels[++i] = new ChannelListJsonModel();
             clModels[i].ChannelList = new List<ChannelModel>();
             clModels[i].ChannelBelong = a.InnerText;
             continue;
         }
         if (i < 0) continue;
         clModels[i].ChannelList.Add(
             new ChannelModel
             {
                 ChannelUrl = a.GetAttributeValue("href", ""),
                 ChannelName = a.InnerText
             });
     }
     Channels = new ObservableCollection<ChannelListJsonModel>(clModels);
 }
开发者ID:superceix,项目名称:BUPT_IPTV,代码行数:32,代码来源:PublicServices.cs


示例18: GetExtendedData

		private static List<Exhibitor> GetExtendedData(List<Exhibitor> exhibitors)
		{
			foreach(var exhibitor in exhibitors)
			{
				string url = baseUrl + exhibitor.DetailUrl;
				string html = WebHelper.HttpGet(url);

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

				exhibitor.Overview = HtmlDocHelper.GetInnerText(doc, "//*[@id=\"page_content_ctl00_ctl00_divDescription\"]");
				exhibitor.Tags = HtmlDocHelper.GetInnerText(doc, "//*[@id=\"page_content_ctl00_ctl00_ulDetailTags\"]");
				exhibitor.Email = HtmlDocHelper.GetInnerText(doc, "//*[@id=\"page_content_ctl00_ctl00_hlEmail\"]");
				exhibitor.Phone = HtmlDocHelper.GetInnerText(doc, "//*[@id=\"page_content_ctl00_ctl00_divTel\"]").Replace("Tel:", "").Trim();
				exhibitor.Fax = HtmlDocHelper.GetInnerText(doc, "//*[@id=\"page_content_ctl00_ctl00_divFax\"]").Replace("Fax:", "").Trim();
				exhibitor.ImageUrl = HtmlDocHelper.GetAttribute(doc.DocumentNode, "//*[@id=\"page_content_ctl00_ctl00_imgExhibitorDetail\"]", "src");
				
				var nodes = doc.DocumentNode.SelectNodes("//ul[@id=\"page_content_ctl00_ctl00_ulDetailAddress\"]/li");
				if(nodes != null)
				{
					List<string> addressParts = new List<string>();
					foreach(var node in nodes)
					{
						addressParts.Add(node.InnerText);
					}
					exhibitor.Address = string.Join(", ", addressParts);
				}
			}
			return exhibitors;
		}
开发者ID:Adameg,项目名称:mobile-samples,代码行数:30,代码来源:ExhibitorManager.cs


示例19: ParseFromAddress

		private async Task ParseFromAddress(string url)
		{
			var response = await new System.Net.Http.HttpClient().GetStreamAsync(url);
			var page = new HtmlAgilityPack.HtmlDocument();
			page.Load(response);
			var itemNodes = page.DocumentNode.SelectNodes("//form[@id='list-form']/div[@class='list-items']/div[@class='percent-wrap']");
			foreach (var item in itemNodes)
			{
				var titleNode = item.SelectNodes(".//p[@class='title']/a").FirstOrDefault();
				var priceNode = item.SelectNodes(".//p[@class='price']").FirstOrDefault();
				string link = titleNode.Attributes["href"].Value;
				string title = titleNode.Attributes["title"].Value;
				double price;
				double.TryParse(priceNode.InnerText.Trim().Replace("US$", "").Replace(".",","), out price);
				var lumenMatch = new Regex(@"\d{3,4}[-\s]?(lm|lumen)", RegexOptions.IgnoreCase).Match(title);
				if (!lumenMatch.Groups[0].Success)
					continue;
				string lumenCountString = Regex.Replace(lumenMatch.Groups[0].Value, "[^0-9]", "");
				int lumenCount;
				if (!int.TryParse(lumenCountString, out lumenCount))
					continue;
				Items.Add(new RowItem
					{
						LumenCount =  lumenCount,
						Price = price,
						Link = "http://dx.com" + link
					});
			}
			this.Title = Items.Count.ToString();
		}
开发者ID:LeoThorsell,项目名称:DealExtremeLuxParser,代码行数:30,代码来源:Alibaba.xaml.cs


示例20: CaptchaImage

        public IPttCaptcha CaptchaImage(IPttRequest request, string htmlSource)
        {
            var htmlDoc = new HtmlAgilityPack.HtmlDocument();
            htmlDoc.LoadHtml(htmlSource);
            var iframe = htmlDoc.DocumentNode.SelectSingleNode("//iframe");
            if (iframe == null)
            {
                return null;
            }
            var iframeSrc = iframe.Attributes["src"].Value;

            var newRequest = new PttRequest(iframeSrc) {WrappedRequest = {ContentType = "text/html", Method = "GET"}};
            IPttResponse response = new PttResponse();
            var captchaFormHtml = response.GetRespon 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# HtmlDocument类代码示例发布时间:2022-05-24
下一篇:
C# HtmlAgilityPack类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap