HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create("http://www.1798.cn/Qybl/ming.asp?id=16606");
HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();
Encoding enc = Encoding.Default;
StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(),enc);
string download = loResponseStream.ReadToEnd();
string companyName = download.Substring(download.IndexOf("class=t3>")+9,download.IndexOf("</FONT>",download.IndexOf("class=t3>")));//公司名称
string linkman = download.Substring(download.IndexOf("class=t2>")+9,download.IndexOf("&nbsp;",download.IndexOf("class=t2>")));//联系人
string tel = download.Substring(download.IndexOf("<font size=\"2\">电 话:")+19,download.IndexOf("<BR>",download.IndexOf("<font size=\"2\">电 话:")));//电 话
string fax = download.Substring(download.IndexOf("传 真:")+4,download.IndexOf("<BR>",download.IndexOf("传 真:")));//传 真
string code = download.Substring(download.IndexOf("邮 编:")+4,download.IndexOf("<BR>",download.IndexOf("邮 编:")));//邮 编
string url = download.Substring(download.IndexOf("网 址:")+4,download.IndexOf("<BR>",download.IndexOf("网 址:")));//网 址
string email = download.Substring(download.IndexOf("Email:")+6,download.IndexOf("<BR>",download.IndexOf("Email:")));//邮 编
string add = download.Substring(download.IndexOf("地 址:")+4,download.IndexOf("</font>",download.IndexOf("地 址:")));//地 址

解决方案 »

  1.   

    http://www.1798.cn/Qybl/search.asp?page=1&sortid=&typeid=&qylb=&title=&cityid=
    共1593页,你一页一页读出就
      

  2.   

    using System;
    using System.Net;
    using System.Text;
    using System.IO;
    namespace ConsoleApplication6
    {
    /// <summary>
    /// Class1 的摘要说明。
    /// </summary>
    class Class1
    {
    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
    HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create("http://www.1798.cn/Qybl/ming.asp?id=16606");
    HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();
    Encoding enc = Encoding.Default;
    StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(),enc);
    string download = loResponseStream.ReadToEnd();
    string companyName = download.Substring(download.IndexOf("class=t3>")+9,download.IndexOf("</FONT>",download.IndexOf("class=t3>"))-download.IndexOf("class=t3>")-9);//公司名称
    string linkman = download.Substring(download.IndexOf("class=t2>")+9,download.IndexOf("&nbsp;",download.IndexOf("class=t2>"))-download.IndexOf("class=t2>")-9);//联系人
    string tel = download.Substring(download.IndexOf("<font size=\"2\">电 话:")+19,download.IndexOf("<BR>",download.IndexOf("<font size=\"2\">电 话:"))-download.IndexOf("<font size=\"2\">电 话:")-19);//电 话
    string fax = download.Substring(download.IndexOf("传 真:")+4,download.IndexOf("<BR>",download.IndexOf("传 真:"))-download.IndexOf("传 真:")-4);//传 真
    string code = download.Substring(download.IndexOf("邮 编:")+4,download.IndexOf("<BR>",download.IndexOf("邮 编:"))-download.IndexOf("邮 编:")-4);//邮 编
    string url = download.Substring(download.IndexOf("网 址:")+4,download.IndexOf("<BR>",download.IndexOf("网 址:"))-download.IndexOf("网 址:")-4);//网 址
    string email = download.Substring(download.IndexOf("Email:")+6,download.IndexOf("<BR>",download.IndexOf("Email:"))-download.IndexOf("Email:")-6);//邮 编
    string add = download.Substring(download.IndexOf("地 址:")+4,download.IndexOf("</font>",download.IndexOf("地 址:"))-download.IndexOf("地 址:")-4);//地 址
    Console.WriteLine(companyName);
    Console.WriteLine(linkman);
    Console.WriteLine(tel);
    Console.WriteLine(fax);
    Console.WriteLine(code);
    Console.WriteLine(url);
    Console.WriteLine(email);
    Console.WriteLine(add);
    Console.ReadLine();
    //
    // TODO: 在此处添加代码以启动应用程序
    //
    }
    }
    }
      

  3.   

    我前段时间刚写了个通用的抓取程序,多线程的,支持任意页面抓取。
    有兴趣可以联系我roket#126.com(把#改为@).
      

  4.   

    群号码:9978078
    群名称:vs.net开发—C#篇
    欢迎大家加入~~~~