Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the DLL component AngleSharp of xHTML source code

2025-04-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

How to understand the DLL component AngleSharp of xHTML source code, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

AngleSharp is a DLL component developed specifically for parsing xHTML source code based on .NET (C #).

Project address: https://github.com/FlorianRappl/AngleSharp

I will mainly introduce some common methods of using AngleSharp. I will use the site as a prototype to introduce to you. Other similar components are:

Domestic: Jumony

Github address: https://github.com/Ivony/Jumony

Abroad: Html Agility Pack

Project address: http://htmlagilitypack.codeplex.com/

Specifically, you can search and compare the differences and performance of the three. Next, we mainly discuss that the protagonist is AngleSharp.

Introduce AngleSharp into the project and use the NuGet tool to execute commands (I'm actually pretending. ) Install-Package AngleSharp

Add a reference Using AngleSharp to the project

First, let's get the HTML source code for the home page of CnBlogs

Static public string GetHtml () {HttpWebRequest myReq = (HttpWebRequest) WebRequest.Create ("https://www.jb51.net"); HttpWebResponse response = (HttpWebResponse) myReq.GetResponse (); / / Get the stream associated with the response. Stream receiveStream = response.GetResponseStream (); / / Pipes the stream to a higher level stream reader with the required encoding format. StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8); return readStream.ReadToEnd ();}

Get the title of all current blog posts on the jb51 home page

Private static void Main (string [] args) {/ / find all article titles string cnblogsHtml = GetHtml (); / / load HTML var document = DocumentBuilder.Html (cnblogsHtml); / / must be used here = = cannot be used Equals var titleItemList = document.All.Where (m = > m.ClassName = = "titlelnk"); int iIndex = 1; foreach (var element in titleItemList) {Console.WriteLine (iIndex+ ":" + element.InnerHtml); iIndex++;}}

The output of the above code:

1:JNDI Learning Summary (3)-- configuring JNDI data sources using Druid under Tomcat 2: how our front end communicates with designers complete 3:MVC5+EF6 tutorial 6: try to discuss the difference between throttle and debounce helper functions in common Javascript class libraries 5: walk alone through youth 6: review of hot spots last week (11.10-11.16) 7:Android animation-Tween animation 8: python reality of naive Bayesian algorithm Now the printing and design of 9:MVC three-layer cascading 10:C# label (bar code) (1) 11:OpenCASCADE Make Primitives-Box12: implementation of secondary index of hbase based on solr 13: (16) discussion on the problems caused by offset compensation in WebGIS 14:javascript Mini Game-Life Game 15:Android Animation-frame Animation 16:C# Socket Learning Notes-17:lua Table sorting 18:ZooKeeper Series 1: ZooKeeper Fast Introduction 19: [plug-in development]-9 editor code block coloring-highlight! 20: University of Washington computer Vision course Notes (1) this is the answer to the question about how to understand the DLL module AngleSharp of xHTML source code. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report