易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net(c#)做一个网页数据采集工具

最近做一个网站,该网站需要添加4000多 产品信息,如果用人工方法去别的网站copy那至少要花费半月时间才能完成,所以我个办法使用c#作出来了一个网页数据采集软件
详细出处参考:http://www.jb51.net/article/21468.htm
//提取产品列表页中产品最终页的网页
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "")
{
MessageBox.Show("网址和域名不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
try
{
string Html = inc.GetHtml("http://study.pctoday.net.cn");
//ArrayList al = inc.GetMatchesStr(Html, "<a[^>]*?>.*?</a>");
ArrayList al = inc.GetMatchesStr(Html, @"href\s*=\s*(?:[\'\""\s](?<1>[^\""\']*)[\'\""])");//提取链接
" title="Replica Watches:">Replica Watches Buy Full Quality Popular Luxury Watches at Amazing Price, Your One Stop Discount Swiss Watches StoreExclusive Replica Rolex Watches, Tag Heuer Watches Replica, Cartier Watches online Sale!
StringBuilder sb = new StringBuilder();
foreach (object var in al)
{
string a = var.ToString().Replace("\"", "").Replace("'", "");
a = Regex.Replace(a, "href=", "", RegexOptions.IgnoreCase | RegexOptions.Multiline);
if (a.StartsWith("/"))
a = textBox2.Text.Trim() + a;
if (!a.StartsWith("http://"))
a = "http://" + a;
sb.Append(a + "\r\n");
}
textBox5.Text = sb.ToString();//把提取到网址输出到一个textBox,每个链接占一行
MessageBox.Show("共提取" + al.Count.ToString() + "个链接", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception err)
{
MessageBox.Show("提取出错!原因:" + err.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
//把采集的产品页面html代码进行字符串处理,提取需要的代码,最后保存到本地一个access数据库中,同时提取产品图片地址并自动现在图片到本地images文件夹下
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
//填充产品表
Database.ExecuteNonQuery("delete from Tb_Product


相关文档:

ASP.NET页面之间传递值的几种方法

一.使用QueryString
Request.QueryString
   在ASP时代,这个是较常用的方法,到了ASP.NET,好像用的人不多了,但是不管怎么说,这是一个没有过时,且很值得推荐的方法,因为不管是ASP还是ASP.NET,最基本的都还是基于HTTp协议的。 缺点是非常明显的,让在多个页面传递时,可能就Request不到了
  使用Qu ......

让你的ASP.NET虚拟主机也支持子网站

  现在ASP.NET虚拟主机一般都可以绑定多个域名,但是通过这几个域名打开的页面都一样。如何使绑的这几个域名分别打开不通的页面(即实现子网站的功能)呢? 其实很简单,只需4个步骤:
    1)给虚拟主机绑定几个域名;例如:www.abc.com,services.abc.com,support.abc.com。
    2 ......

Asp.Net 默认按钮

方法一:
function document.onkeydown() 

    if(event.keyCode==13) 
    { 
        document.form1.all.Submit.click();    //这里的submit是按钮的ID
    } 
}
方法二:
......

在ASP.Net 2.0中实现多语言界面的方法

 1. 跟以前一样做界面,只是注意,把所有需要有多语言界面的文字都用label来做
  2. 做完以后,在Solution Explorer里选中这个文件,选Tools->Generate Local Resource
  3. 你会发现生成了一个目录,App_LocalResources;这个目录里多了一个resx的文件。比如你的aspx文件是default.aspx,它就会生成一个叫做de ......

Asp.net 数据采集基类(远程抓取,分解,保存,匹配)


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MSXML2;
using System.Text.RegularExpressions; ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号