zoukankan
html css js c++ java
简单的信息采集程序示例(小偷程序) (转)
简单的信息采集程序示例(小偷程序)
最近正准备做一个信息采集的程序,下面是一个简单的采集程序,提供给初学者入门参考。
aspx页面代码
<
asp:TextBox ID
=
"
Txt_Url
"
runat
=
"
server
"
Width
=
"
441px
"
></
asp:TextBox
><
br
/>
<
asp:Button id
=
"
Btn_GetUrlSource
"
runat
=
"
server
"
Text
=
"
取得网页代码
"
OnClick
=
"
Btn_GetUrlSource_Click
"
></
asp:Button
>
<
br
/>
<
asp:TextBox id
=
"
Txt_UrlSource
"
runat
=
"
server
"
Width
=
"
100%
"
Height
=
"
195px
"
TextMode
=
"
MultiLine
"
></
asp:TextBox
><
br
/>
<
br
/>
采集开始代码
<
asp:TextBox ID
=
"
Txt_First
"
runat
=
"
server
"
Height
=
"
90px
"
TextMode
=
"
MultiLine
"
Width
=
"
280px
"
></
asp:TextBox
><
br
/>
<
asp:Button ID
=
"
Btn_ListCheck
"
runat
=
"
server
"
OnClick
=
"
Btn_ListCheck_Click
"
Text
=
"
测试唯一性
"
/><
br
/>
采集结束代码
<
asp:TextBox ID
=
"
Txt_Last
"
runat
=
"
server
"
Height
=
"
90px
"
TextMode
=
"
MultiLine
"
Width
=
"
280px
"
></
asp:TextBox
><
br
/>
<
br
/>
<
asp:Button ID
=
"
Btn_Result
"
runat
=
"
server
"
Text
=
"
取得采集结果
"
OnClick
=
"
Btn_Result_Click
"
/><
br
/>
<
asp:TextBox ID
=
"
Txt_Result
"
runat
=
"
server
"
Height
=
"
134px
"
TextMode
=
"
MultiLine
"
Width
=
"
579px
"
></
asp:TextBox
>
.cs页面代码
using
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Web;
using
System.Web.SessionState;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.HtmlControls;
using
System.IO;
using
System.Net;
using
System.Text.RegularExpressions;
using
NetShuai.Database;
private
string
PageUrl
=
""
;
private
void
Page_Load(
object
sender, System.EventArgs e)
{
//
在此处放置用户代码以初始化页面
}
protected
void
Btn_GetUrlSource_Click(
object
sender, EventArgs e)
{
PageUrl
=
Txt_Url.Text;
WebRequest request
=
WebRequest.Create(PageUrl);
WebResponse response
=
request.GetResponse();
Stream resStream
=
response.GetResponseStream();
StreamReader sr
=
new
StreamReader(resStream, System.Text.Encoding.Default);
Txt_UrlSource.Text
=
sr.ReadToEnd();
resStream.Close();
sr.Close();
}
protected
void
Btn_Result_Click(
object
sender, EventArgs e)
{
string
strExp;
strExp
=
@"
(?<=
"
+
Server.HtmlEncode(Txt_First.Text)
+
"
)[\w\W]*?(?=
"
+
Server.HtmlEncode(Txt_Last.Text)
+
"
)
"
;
MatchCollection mc
=
Regex.Matches(Server.HtmlEncode(Txt_UrlSource.Text), strExp);
for
(
int
i
=
0
; i
<
mc.Count; i
++
)
{
Txt_Result.Text
+=
Server.HtmlDecode(mc[i].Value);
}
}
protected
void
Btn_ListCheck_Click(
object
sender, EventArgs e)
{
string
strExp;
strExp
=
Server.HtmlEncode(Txt_First.Text);
MatchCollection mc
=
Regex.Matches(Server.HtmlEncode(Txt_UrlSource.Text), strExp);
if
(mc.Count
>
1
)
{
Response.Write(
"
<script>alert('列表开始代码有重复!')</script>
"
);
return
;
}
strExp
=
Server.HtmlEncode(Txt_Last.Text);
mc
=
Regex.Matches(Server.HtmlEncode(Txt_UrlSource.Text), strExp);
if
(mc.Count
>
1
)
{
Response.Write(
"
<script>alert('列表结束代码有重复!')</script>
"
);
return
;
}
}
查看全文
相关阅读:
Pythonday01
PYTHON_DAY2
PYTHON_DAY3
数据字典生成SQL语句
Spring cloud Netflix >readMe
SecureCRT的安装与激活
MyBatis映射文件UserMapper.xml(mysql环境)
数据库模糊查询4种用法
MyBatis配置文件myBatisconfig.xml
计算机基础:2进制和2进制算法。
原文地址:https://www.cnblogs.com/zhangzheny/p/901722.html
最新文章
真机调试
[c#] WebQQ密码MD5加密算法的C#实现
[c#] 网络协议模拟之QQ微博分享接口应用
[c#] WebQQ群发限制的突破[续]
[c#] WebQQ群发限制的突破
[c#] 断点续传下载文件[带进度条类似迅雷]
[c#] 基础之老生常谈——委托
[c#] 协议模拟编程之ADSL模式下IP自动换
[c#] 多线程网络编程应用[多线程文章采集]
[c#] 用正则表达式和js轻松处理json文本
热门文章
C# 两种方法实现HTTP协议迷你服务器
编写VBA宏生成页面
沫沫金原创提供:完整的根据身份证获取省份、性别、年龄、生日及页面验证
CSS一个属性,让图片后的文字垂直居中,效果看得见
oracle 28001错误 密码过期失效
CSS背景图片垂直居中center不起效果完美解决
设置联想键盘恢复F1~F12默认按键的操作办法
同学整理的关于二叉树问题之已知两种序列求第三种
完全二叉树已知总结点求叶结点
linux tcp协议定时器
Copyright © 2011-2022 走看看