我想完成,网页中特定信息的提取,比如我在百度中输入IP,就会得到IP所对应的实际地址,如这样:http://www.baidu.com/s?wd=120.120.120.120
我想提取其中的实际地址,要怎么写啊?(C#的更好)

解决方案 »

  1.   

    在百度中输入IP:120.120.120.120    会得到这个IP对应实际地址:台湾  
      

  2.   

    现在访问不了百度,jiangshun给解决吧
      

  3.   

    下面是百度IP查询网页中的部分代码:
    <p style="line-height:120%;padding:0 0 0 15px;font-size:14px;margin:0px;">您查询的IP:<strong style="color:#c60a00">120.120.120.120</strong>&nbsp;&nbsp;&nbsp;&nbsp;来自:台湾&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;此数据由<a href="http://www.ip138.com/" target="_blank">ip138</a>提供<br></p><br>我只想提取其中的"台湾",后面好像也会出现这两个字.要怎么才能完成?
      

  4.   

    try...            Regex reg = new Regex(@"(?<=来自:)[^&]+(?=&nbsp;)");
                Match m = reg.Match(yourStr);
                if (m.Success)
                {
                    richTextBox2.Text = m.Value;
                }
      

  5.   


            public static string getHTMl(string strIP)
            {
                WebClient client = new WebClient();
                Byte[] pageData = client.DownloadData("http://www.baidu.com/s?wd="+strIP);
                string html = Encoding.Default.GetString(pageData);
                Regex reg = new Regex(@"(?is)(?<=来自:).*(?=(&nbsp;)+此数据由)");
                return reg.Match(html).Value.ToString();
                
            }基本可以,顺便请教一下过客,&nbsp;这个我怎么排除不了啊,
    出来的结果是:台湾&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;