C# 强大的网页处理类NSoup
地址: https://github.com/GeReV/NSoup
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
namespace NSoupDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
WebClient webClient = new WebClient();
string htmlString = Encoding.GetEncoding("UTF-8").GetString(webClient.DownloadData("https://blog.csdn.net/lw112190/article/details/106143263"));
NSoup.Nodes.Document NSoupDoc = NSoup.NSoupClient.Parse(htmlString);
var title = NSoupDoc.Body.Select(".title-article").Html();
textBox1.Text = title;
}
}
}
效果