|
方法1: 用file_get_contents 以get方式獲取內(nèi)容:
<?php$url='http://www.jb51.NET/';$html = file_get_contents($url);echo $html;?>
方法2: 用fopen打開url, 以get方式獲取內(nèi)容:
<?php$fp = fopen($url, ‘r');stream_get_meta_data($fp);while(!feof($fp)) {$result .= fgets($fp, 1024);}echo “url body: $result”;fclose($fp);?>
方法3:用file_get_contents函數(shù),以post方式獲取url
<?php$data = array (‘foo' => ‘bar');$data = http_build_query($data);$opts = array (‘http' => array (‘method' => ‘POST',‘header'=> “Content-type: application/x-www-form-urlencodedrn” .“Content-Length: ” . strlen($data) . “rn”,‘content' => $data));$context = stream_context_create($opts);$html = file_get_contents(‘http://localhost/e/admin/test.html', false, $context);echo $html;?>
方法4:用fsockopen函數(shù)打開url,以get方式獲取完整的數(shù)據(jù),包括header和body,fsockopen需要 php.ini 中 allow_url_fopen 選項開啟
<?phpfunction get_url ($url,$cookie=false){$url = parse_url($url);$query = $url[path].”?”.$url[query];echo “Query:”.$query;$fp = fsockopen( $url[host], $url[port]?$url[port]:80 , $errno, $errstr, 30);if (!$fp) {return false;} else {$request = “GET $query HTTP/1.1rn”;$request .= “Host: $url[host]rn”;$request .= “Connection: Closern”;if($cookie) $request.=”Cookie: $cookien”;$request.=”rn”;fwrite($fp,$request);while(!@feof($fp)) {$result .= @fgets($fp, 1024);}fclose($fp);return $result;}}//獲取url的html部分,去掉headerfunction GetUrlHTML($url,$cookie=false){$rowdata = get_url($url,$cookie);if($rowdata){$body= stristr($rowdata,”rnrn”);$body=substr($body,4,strlen($body));return $body;}return false;}?>
方法5:用fsockopen函數(shù)打開url,以POST方式獲取完整的數(shù)據(jù),包括header和body
<?phpfunction HTTP_Post($URL,$data,$cookie, $referrer=”"){// parsing the given URL$URL_Info=parse_url($URL);// Building referrerif($referrer==”") // if not given use this script as referrer$referrer=”111″;// making string from $dataforeach($data as $key=>$value)$values[]=”$key=”.urlencode($value);$data_string=implode(“&”,$values);// Find out which port is needed 主站蜘蛛池模板: 久久99蜜桃精品麻豆 | 强奷乱码中文字幕熟女免费 | 116美女写真成人午夜视频 | 国产亚洲精品久久久999蜜臀 | 欧美freesex黑人又粗又 | 语文老师扒开胸罩喂我奶 | 国产在线高清视频无码不卡 | 9420高清完整版在线电影免费观看 | 草699一码二码三码四码 | 久久精品国产亚洲AV未满十八 | 亚洲人成色777777老人头 | 久久亚洲精品中文字幕 | 出租屋交换人妻 全文 | 亚洲精品免费网站 | 国产在线亚洲精品观看不卡 | 真实国产乱子伦精品一区二区三区 | 国产国产乱老熟女视频网站97 | 激情床戏视频片段有叫声 | 日韩免费一级毛片 | 一个色综合久久 | 捆绑白丝粉色JK震动捧喷白浆 | 亚洲精品第一页 | 伊人久久亚洲精品一区 | 91看片淫黄大片.在线天堂 | 亚洲精品久久久久无码AV片软件 | 亚洲免费在线播放 | xxx免费观看 | 视频一区二区三区蜜桃麻豆 | 区产品乱码芒果精品P站在线 | 国内精品免费视频精选在线观看 | YELLOW视频直播在线观看 | 日本二区三区欧美亚洲国 | 国产成人亚洲精品无广告 | 伊人青青草 | 日本xxxx裸体xxxx | 中文字幕在线久热精品 | 被窝国产理论一二三影院 | 日本内射精品一区二区视频 | 259luxu高跟黑色丝袜系列 | 亚洲精品国偷拍电影自产在线 | 冠希和阿娇13分钟在线视频 |