当前位置: 首页>>代码示例>>C#>>正文


C# HtmlAgilityPack.HtmlDocument.LoadHtml方法代码示例

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


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

示例1: 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

示例2: Regex

        /// <summary>
        /// 返回 报关单号, 报关单pre_entry_id
        /// </summary>
        /// <param name="htmlInfo"></param>
        /// <returns></returns>
        internal static Dictionary<string, string> Parse查询所有报关单号2(string htmlInfo)
        {
            Dictionary<string, string> dic = null;
            HtmlAgilityPack.HtmlDocument _html = new HtmlAgilityPack.HtmlDocument();
            _html.LoadHtml(htmlInfo);

            HtmlAgilityPack.HtmlNode node_table = _html.DocumentNode.SelectSingleNode("/html[1]/body[1]/table[2]");
            if (node_table != null)
            {
                dic = new Dictionary<string, string>();
                int trCount = new Regex("<tr>").Matches(node_table.InnerHtml).Count;
                for (int i = 2; i <= trCount; i++)
                {
                    //报关单号
                    HtmlAgilityPack.HtmlNode node_td1 = _html.DocumentNode.SelectSingleNode(string.Format("/html[1]/body[1]/table[2]/tr[{0}]/td[2]/div[1]/a[1]", i));
                    //地址
                    HtmlAgilityPack.HtmlNode node_td2 = _html.DocumentNode.SelectSingleNode(string.Format("/html[1]/body[1]/table[2]/tr[{0}]/td[7]/div[1]/a[1]", i));
                    string url = null;
                    if (node_td2 != null)
                    {
                        //去掉“../”,拼成报关单快照url
                        //url = "http://www.nbedi.com/h2000eport/pre_bgd/" + node_td2.InnerText.Substring(3);

                        //报关单pre_entry_id
                        string att = node_td2.Attributes["href"].Value;
                        url = att.Substring(att.LastIndexOf("=") + 1);
                    }
                    dic.Add(node_td1.InnerText, url);
                }
            }
            return dic;
        }
开发者ID:qq5013,项目名称:mERP-HD,代码行数:37,代码来源:PageAnalyze.cs

示例3: 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

示例4: 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

示例5: GetSalestates

        public Salestate[] GetSalestates()
        {
            var http_salestate_list_url = "https://creator.toranoana.jp/portal/salestate_list.cgi";
            var salestate_page_key = "salestate_page";

            WebClientEx webClient = new WebClientEx();
            webClient.CookieContainer = Cookie;

            // 売上ページ一覧を取得
            var buffer = webClient.DownloadData(http_salestate_list_url);
            var htmlString = ConvertHtmlBufferToString(buffer);

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

            // 売上ページのみへのリンク取得
            var saleStateLinks = doc.DocumentNode.SelectNodes("//a").Where(_=>_.GetAttributeValue("href", "").Contains(salestate_page_key));

            var baseURI = new Uri(http_salestate_list_url);
            List<Salestate> salestates = new List<Salestate>();
            foreach (var link in saleStateLinks)
            {
                // 売上ページを走査
                var uri = new Uri( baseURI, link.GetAttributeValue("href", ""));
                salestates.Add(GetSalestate(webClient, uri.ToString()));
            }

            return salestates.ToArray();
        }
开发者ID:neetpia,项目名称:DoujinKaikei,代码行数:29,代码来源:Program.cs

示例6: 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

示例7: 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

示例8: 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

示例9: 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.GetResponse(newRequest);

            htmlDoc = new HtmlAgilityPack.HtmlDocument();
            htmlDoc.LoadHtml(captchaFormHtml);
            var captchaImg = htmlDoc.DocumentNode.SelectSingleNode("//img");
            if (captchaImg == null)
            {
                return null;
            }
            var captchaSrc = string.Format("http://{0}/recaptcha/api/{1}", googleHost, captchaImg.Attributes["src"].Value);

            return new PttCaptcha() { Url = captchaSrc, RequestUsed = newRequest, FormUrl = iframeSrc};
        }
开发者ID:yukseljunk,项目名称:wps,代码行数:26,代码来源:NatalieCaptcha.cs

示例10: GetTransfersData

        /// <summary>
        /// Get all transfers data as list of strings.
        /// </summary>
        /// <param name="htmlDocument">HTML document string representation.</param>
        /// <returns>String list of data.</returns>
        public List<String> GetTransfersData(string htmlDocument)
        {
            // Data container.
            List<string> dataToSave = new List<string>();

            // Load downloaded website.
            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
            htmlDoc.LoadHtml(htmlDocument);

            // Find proper HTML element with transfers 'table'.
            HtmlAgilityPack.HtmlNode div = htmlDoc.DocumentNode.SelectSingleNode("//div[@class='panes']");

            // Get all players with data, each data element as separate list element.
            if (div != null)
            {
                dataToSave = div.Descendants("li")
                               .Select(a => a.InnerText)
                               .ToList();
            }
            else
            {
                throw new Exception("Could not find div with transfers!");
            }

            return dataToSave;
        }
开发者ID:Alakair,项目名称:data-refine,代码行数:31,代码来源:TransferManager.cs

示例11: 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

示例12: getGalleryResponse

        void getGalleryResponse(IAsyncResult result)
        {
            HttpWebRequest request = result.AsyncState as HttpWebRequest;
            if (request != null)
            {
                try
                {
                    WebResponse response = request.EndGetResponse(result);
                    Stream outStream = response.GetResponseStream();
                    StreamReader reader = new StreamReader(outStream);
                    string xmlResult = reader.ReadToEnd();
                    
                    HtmlAgilityPack.HtmlDocument xdoc = new HtmlAgilityPack.HtmlDocument();
                    xdoc.LoadHtml(xmlResult);

                    HtmlAgilityPack.HtmlNodeCollection posts = xdoc.DocumentNode.SelectNodes("tumblr/posts/post[@type='photo']");
                    foreach (HtmlAgilityPack.HtmlNode post in posts)
                    {
                        string targetUri = post.SelectSingleNode("photo-url[@max-width='400']").InnerHtml;
                        imageUriList.Add(targetUri);
                    }
                    populatePivot();
                }
                catch (WebException e)
                {
                   return;
                }
            }
        }
开发者ID:DonnaLou,项目名称:SummonersHQ,代码行数:29,代码来源:FanArtGalery.xaml.cs

示例13: 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

示例14: Main

        static void Main(string[] args)
        {
            string html =
                @"<div class=""article-content"">
                   <p>text I want text I want text I want text I want <strong> TEXT I WANT TOO </strong></p>
                   <p>text I want text I want text I want text I want <strong> TEXT I WANT TOO </strong></p>
                </div>";

            using (WebClient client = new WebClient())
            {
                client.Encoding = System.Text.Encoding.Unicode;
                var doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(html);

                var nodes = doc.DocumentNode.SelectNodes("//div[@class='article-content']/p");

                nodes.ToList().ForEach(n =>
                {
                    Console.WriteLine(n.InnerText);
                });

                Console.ReadLine();

            }
        }
开发者ID:st4hoo,项目名称:HtmlAgilityPackTest,代码行数:25,代码来源:Program.cs

示例15: 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


注:本文中的HtmlAgilityPack.HtmlDocument.LoadHtml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。