visual studio 2010下 C# 编写的一个简单的网页源代码分析、链接抓取器
先上图:
使用方法:
只要输入网址、用于匹配链接的正则表达式、补充的前缀就可以抓取到整个页面的所有符合条件的链接,
并且会在C盘生成一个TXT文件保存链接。
如果再进一步设计,可以设计成抓取全站的链接,但是目前不太了解具体实现方法,所以就暂时不做下去了。
主要代码:
Form1.cs
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;//web操作命名空间
using System.IO;//读取文件流命名空间
using System.Text.RegularExpressions;//正则表达式命名空间
namespace 网页源代码分析抓取
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) //抓取链接
{
string input = richTextBox1.Text;