页面信息抓取

这两天在整这个,提取某一个网站的信息,不断学习中.......
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
//根据 url 读取 源文件
         public string GetSourceHtml(string urlstr)
        {
            WebRequest wreq = WebRequest.Create(urlstr);
            WebResponse wres = wreq.GetResponse();
            Stream rece = wres.GetResponseStream();

            Byte[] read = new Byte[512];
            int bytes = rece.Read(read, 0, 512);

            string reshtml = "";
            while (bytes > 0)
            {
                Encoding encode = Encoding.GetEncoding("gb2312");
                reshtml += encode.GetString(read, 0, bytes);
                bytes = rece.Read(read, 0, 512);
            }
            return reshtml;
        }
//提取源文件中 相关的 url
.......
//提取源文件中的文章内容,去掉页面的头尾。
.......
定位页面中内容的一点想法:
现在要提取的内容就是提取只包含内容的表格,而去掉其它的,可以根据不需要的内容的一些关键字,去掉那些表格并根据标题,位置和内容中的一些固定元素判断内容所在的具体位置,从而实现提取。

转载于:https://www.cnblogs.com/lihuiping258/archive/2007/04/02/697251.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值