百度文库内容复制 C# webbrowser+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)
{
NSoup.Nodes.Document NSoupDoc = NSoup.NSoupClient.Parse(webBrowser1.Document.Body.InnerHtml);
var strpagecount = NSoupDoc.Body.Select(".page-count").Text;
if (strpagecount.Contains("/"))
{
strpagecount = strpagecount.Replace("/", "");
}
int pagecount = 0;
if (!int.TryParse(strpagecount, out pagecount))
{
MessageBox.Show("页数处理失败");
return;
}
StringBuilder content = new StringBuilder();
for (int i = 0; i < pagecount; i++)
{
content.Append(NSoupDoc.Body.Select("#pageNo-"+(i+1)).Text);
}
Form2 frm = new Form2();
frm.richTextBox1.Text= content.ToString();
frm.Show();
}
private void button2_Click(object sender, EventArgs e)
{
webBrowser1.Url = new Uri(textBox1.Text);
}
}
}
文中内容可查看Linux安装Oracle12C