<?php
header('access-allow-origin:*');
sleep(1);
echo "hello\n";
echo "world";
<?php
$url = 'http://localhost/test.php';
$output = file($url);
var_dump($output);
b. 輸出:
十年的下冶網站建設經驗,針對設計、前端、開發、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都全網營銷的優勢是能夠根據用戶設備顯示端的尺寸不同,自動調整下冶建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現優雅布局與設計,從而大程度地提升瀏覽體驗。成都創新互聯從事“下冶網站設計”,“下冶網站推廣”以來,每個客戶項目都認真落實執行。
array(2) {
[0]=>
string(6) "hello"
[1]=>
string(5) "world"
}
<?php
$url = 'http://localhost/test.php';
$output = file_get_contents($url);
var_dump($output);
b. 輸出:
string(11) "hello world"
<?php
$url = 'http://localhost/test.php';
$handle = fopen($url,"rb");
do{
$data = fread($handle,1024);
if(strlen($data)==0) {
break;
}
$output = $data;
}
while(true);
fclose($handle);
var_dump( $output);
b. 輸出:
string(11) "hello world"
<?php
$url = 'http://localhost/test.php';
$ch = curl_init();
$timeout = 1;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$output = curl_exec($ch);
curl_close($ch);
var_dump($output);
b. 輸出:
string(11) "hello world"
<?php
$url = 'localhost/test.php';
$fp = fsockopen($url, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
stream_set_blocking($fp,0);
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: {$url}\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
var_dump(fgets($fp, 128));
}
fclose($fp);
}
b. 輸出:
string(11) "hello world"
當前題目:php執行抓取網頁的幾種方式
網頁鏈接:http://vcdvsql.cn/article14/gjehde.html
成都網站建設公司_創新互聯,為您提供企業網站制作、定制開發、ChatGPT、移動網站建設、網站策劃、靜態網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯