这个网址http://myunghae.cn.alibaba.com/athena/contact/myunghae.html上的内容怎么抓取为什么我抓取这个页面的HTML代码取不到呢?麻烦会的帮助一下

解决方案 »

  1.   

    最后获取到的是<html><head><meta HTTP-EQUIV="Content-Type" Content="text/html; charset=gb2312"><title ID=titletext>建设中</title></head><body bgcolor=white><table><tr><td ID=tableProps width=70 valign=top align=center><img ID=pagerrorImg src="pagerror.gif" width=36 height=48><td ID=tablePropsWidth width=400><h1 ID=errortype style="font:14pt/16pt 宋体, verdana; color:#4e4e4e"><P ID=Comment1><!--Problem--><P ID="errorText">建设中</h1><P ID=Comment2><!--Probable causes:<--><P ID="errordesc"><font style="font:9pt/12pt 宋体; color:black">  您想要查看的站点当前没有默认页。可能正在对它进行升级和配置操作。<P ID=term1>请稍后再访问此站点。如果您仍然遇到问题,请与网站的管理员联系。<hr size=1 color="blue"><P ID=message1>如果您是网站的管理员,并且认为您是由于错误才收到此消息,请参阅 IIS 帮助中的&quot;启用和禁用动态内容&quot;。<h5 ID=head1>要访问 IIS 帮助</h5><ol><li ID=bullet1>单击<b>开始</b>,然后单击<b>运行</b>。<li ID=bullet2>在<b>打开</b>文本框中,键入 <b>inetmgr</b>。将出现 IIS 管理器。<li ID=bullet3>从<b>帮助</b>菜单,单击<b>帮助主题</b>。<li ID=bullet4>单击<b>Internet 信息服务</b>。</ol></td></tr></table></body></html>和网页上的源代码完全不符
      

  2.   

    代码贴出来,看看啊
     private void GetWeather()
        {
            //根据地图可得知相应的代码
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("");
            request.Method = "Get";
            request.ContentType = "application/x-www-form-urlencoded";
            WebResponse response = request.GetResponse();
            Stream s = response.GetResponseStream();
            StreamReader sr = new StreamReader(s, System.Text.Encoding.GetEncoding("GB2312"));
            string html = sr.ReadToEnd();
            s.Close();
            sr.Close();
            Response.Write(html);
            //Response.Write(html);
        }
      

  3.   

    1 首先现在源文件
    /// <summary>
            ///  获取指定网页的HTML代码 
            /// </summary>
            /// <param name="URL">网址</param>
            /// <returns></returns>
            static string GetPageSource(string URL)
            {
                System.Net.WebClient wc = new System.Net.WebClient();
                Byte[] pageData = wc.DownloadData(URL);
                wc.Credentials = System.Net.CredentialCache.DefaultCredentials;
                return System.Text.Encoding.Default.GetString(pageData);
            }
    如果这个获取不到源文件的话就用WebBrowser控件来取HTML2 进行对HTML进行分析
    利用字符截取的方式来进行数据提取
    #region 字符截取
            /// <summary>
            /// 字符截取
            /// </summary>
            /// <param name="beginstr">开始字符串</param>
            /// <param name="endstr">结束字符串</param>
            /// <param name="HTML">源文件</param>
            /// <returns></returns>
            public static string Interception(string beginstr, string endstr, string HTML)
            {
                try
                {
                    //根据开头字符的位置和结束字符的位置,取出中间的字符规范
                    int beg = HTML.IndexOf(beginstr);
                    int end = HTML.IndexOf(endstr);
                    string cmdtext = HTML.Substring(beg + beginstr.Length, end - beg - beginstr.Length);
                    return cmdtext;
                }
                catch
                {
                    return "";
                }
            }
            #endregion
    比如string HTML="<li><a href="http://www.csdn.net/" target=_blank>首页</a>|</li>"要取”首页“
    调用这个函数Interception("target=_blank>","</a>|</li>",HTML);接下来你要自己来做了
      

  4.   

    你抓取的url是http://myunghae.cn.alibaba.com/athena/contact/myunghae.html吗?