PS:本来想带个“IP纯真数据库”走的,但是感觉那个太麻烦了,还要带个几M的附件走,感觉不爽
所以就从“ip138”的网页中正则出“IP物理地址”,源代码如下:
private: System::String^ lv_net_port_getIPAddr(String^ str_) { try { //web客户端 WebClient^ webclient = gcnew WebClient(); //下载数据 str_ = webclient->DownloadString(“http://www.ip138.com/ips8.asp ip=”+str_+”&action=2 “); //正则 String^ str_regex = “ .*”; //忽略大小写 Regex^ regex = gcnew Regex(str_regex, RegexOptions::IgnoreCase); //开始匹配 MatchCollection^ matchCollection = regex->Matches(str_); //获得匹配字符串 for (int i = 0; i < matchCollection->Count; i++) { return matchCollection[i]->Value->Split(gcnew array {“”},StringSplitOptions::RemoveEmptyEntries) [2]->Replace(“”,”")->Replace(“参考数据二:”,”"); } } catch(Exception^ ex){ return “”; } }
原文地址:http://www.badteen.net/ post=299
|