时间:2021-07-01 10:21:17 帮助过:25人阅读
一套程序中需要在指定的URL页面中提取里面所有的域名,现代码如下:
$CODE = ......;//这里是获取远程的URL内容 $temp = "//i"; preg_match_all( $temp, $CODE, $Jzz_thlld ); $Jzz_thlld = $Jzz_thlld[0]; $temp = "/ href=[\"']?http:\\/\\/www\\.([^>\"' ]+)[\"']?\\s*[^>]*>(.*)<\\/a>/si"; for ($dos_skipping = 0; $dos_skipping < sizeof( $Jzz_thlld ); $dos_skipping++ ) { preg_match( $temp, $Jzz_thlld[$dos_skipping], $tempurl ); if ( !( $tempurl[1] != "" ) && !( strpos( $tempurl[1], "?" ) === FALSE ) && !( strpos( $tempurl[1], "&" ) === FALSE ) && !( strpos( $tempurl[1], "#" ) === FALSE ) && !( strpos( $tempurl[1], ":" ) === FALSE ) && !( strpos( $tempurl[1], " " ) === FALSE ) ) { echo '99'; $url_temp = "www.".$tempurl[1]; if ( 0 < strpos( $url_temp, "/" ) ) { $url_arr = explode( "/", $url_temp ); $url_temp = $url_arr[0]; } if ( $Jzz_cbgsf == "" ) { $Jzz_cbgsf = $url_temp; } else if ( strpos( "||".$Jzz_cbgsf."||", "||".$url_temp."||" ) === FALSE ) { $Jzz_cbgsf .= "||".$url_temp; } } }
上述代码中不能按照需求获取到所需要的信息,忘各位帮忙看看,改如何修改!!