首頁  >  文章  >  後端開發  >  !帮小弟我看看这个娶图函数到底出错在哪

!帮小弟我看看这个娶图函数到底出错在哪

WBOY
WBOY原創
2016-06-13 12:44:05806瀏覽

大虾!帮我看看这个娶图函数到底出错在哪~

<br />
function get_content_by_socket($url){ <br />
$url = eregi_replace('^http://', '', $url);<br />
$temp = explode('/', $url);<br />
$host = array_shift($temp);<br />
$url = ''.implode('/', $temp);<br />
$temp = explode(':', $host);<br />
$host = $temp[0];<br />
$port = isset($temp[1]) ? $temp[1] : 80;<br />
//echo $url;<br />
//echo $host;<br />
   $fp = fsockopen($host, 80) or die("Open ". $url ." failed"); <br />
    $header = "GET /".$url ." HTTP/1.1\r\n"; <br />
    $header .= "Accept: */*\r\n"; <br />
    $header .= "Accept-Language: zh-cn\r\n"; <br />
   $header .= "Accept-Encoding: gzip, deflate\r\n"; <br />
   $header .= "If-Modified-Since: Tue, 06 Apr 2010 07:56:03 GMT; length=2235\r\n"; <br />
    $header .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.4)\r\n"; <br />
    $header .= "Host: ". $host ."\r\n"; <br />
	$header .= "Referer: http://video.baidu.com/v?word=11&ct=301989888&rn=20&pn=0&db=0&s=0&fbl=800\r\n"; <br />
	//fputs($content, "Referer: $domainrn");//伪造部分 <br />
    $header .= "Connection: Keep-Alive\r\n"; <br />
    $header .= "Cookie: BAIDUID=5F96971273579588527A980F307E8B7A:FG=1\r\n\r\n"; <br />
    //$header .= "Connection: Close\r\n\r\n"; <br />
<br />
    fwrite($fp, $header); <br />
    while (!feof($fp)) { <br />
        $contents .= fgets($fp, 8192); <br />
    } <br />
    fclose($fp); <br />
    return $contents; <br />
} 



函数可以正常使用 但是取图的速度非常慢

而且当同时取三到四张时就一张也取不到

PHP
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn