网址:http://detail.zol.com.cn/category/272.html需要获取的数据:品牌图片以及连接文字(不要连接地址)。数据库:Sqlserver2000.是一个控制台的程序。编程语言:Csharp(.net)申明:谢谢各位。

解决方案 »

  1.   

    //使用下面的函数 读取 你的网页 地址 代码 后对获取的内容 进行分析//--需要引用 using System.Net 以及 using System.IO;
    private string GetContentFromUrll(string _requestUrl)
            {
                string _StrResponse ="";
                HttpWebRequest _WebRequest = ( HttpWebRequest )WebRequest.Create( _requestUrl );
                _WebRequest.Method = "GET";
                WebResponse _WebResponse = _WebRequest.GetResponse();
                StreamReader _ResponseStream = new StreamReader( _WebResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("gb2312"));
                _StrResponse = _ResponseStream.ReadToEnd();
                _WebResponse.Close(); 
                _ResponseStream.Close();
                return _StrResponse;        
            }
      

  2.   

    一页一页的打开,然后自己输入数据库。为什么我这样说呢,因为这样写出来的程序根本不通用,万一哪天ZOL改变界面了,什么都没用。
      

  3.   

    给点酬劳,我帮你写.
    -----------------------
          CSDN 论坛助手 
      http://china-csdn.cn
      

  4.   

    hertcloud(·£孙子兵法£·)  的方法  +  正则表达 就可以了
      

  5.   

    当然是HTML源码里的文件~ 翻页的话 找到翻页字符串规律 就可以了
      

  6.   

    好啊!这是你告诉我的代码:using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Net;
    using System.IO;namespace ConsoleApplication3
    {
        class Program
        {
            static void Main(string[] args)
            {
                WebClient mywebclient = new WebClient();
                mywebclient.Credentials = CredentialCache.DefaultCredentials;
                byte[] datahtml = mywebclient.DownloadData("http://detail.zol.com.cn/category/272.html");
                string yourStr = Encoding.Default.GetString(datahtml);            MatchCollection mc = Regex.Matches(yourStr, @"(<div\s+class=""manu_elem"">\s*<div\s+class=""manu_photo"">[\s\S]*?<img\s+src='(?<img>[^']*)'[^>]*>\s*</a>\s*</div>\s*<div\s+class=""manu_name"">(\s*<[^>]*>\s*)+(?<text>[^<>]*)</a>\s*</div>|<div\s+class=""manu_"">[\s\S]*?<a\s+[^>]*>\s*(?<text>[^<>]*)</a>\s*</div>)", RegexOptions.IgnoreCase);
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Groups["text"].Value + "\n" + m.Groups["img"].Value + "");
                }
                Console.ReadLine();
     
            }
        }
    }
    是运行成功了,数据也读取出来了。但是如何插入到数据库里面去啊
      

  7.   

    我的测试代码,假设数据库为test1,表为mytest,图片地址和文字链接所对应的字段分别为img和text            
                SqlConnection con = new SqlConnection("server=CNN;database=test1;uid=sa;password=");
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;
                con.Open();
                string yourStr = richTextBox1.Text;
                MatchCollection mc = Regex.Matches(yourStr, @"(<div\s+class=""manu_elem"">\s*<div\s+class=""manu_photo"">[\s\S]*?<img\s+src='(?<img>[^']*)'[^>]*>\s*</a>\s*</div>\s*<div\s+class=""manu_name"">(\s*<[^>]*>\s*)+(?<text>[^<>]*)</a>\s*</div>|<div\s+class=""manu_"">[\s\S]*?<a\s+[^>]*>\s*(?<text>[^<>]*)</a>\s*</div>)", RegexOptions.IgnoreCase);
                foreach (Match m in mc)
                {
                    //Console.WriteLine(m.Groups["text"].Value + "\n" + m.Groups["img"].Value + "");
                    cmd.CommandText = "insert into mytest(img, text) values('" + m.Groups["img"].Value.Replace("'","") + "','" + m.Groups["text"].Value.Replace("'","") + "')";
                    cmd.ExecuteNonQuery();
                }
                con.Close();