很多php新手在开发自己的网站采集功能时都会直接用到file_get_contents来读取或fopen是吧,是吧,我们下载采集功能加强了了一点点就是要对方的防盗链都不能防止的采集功能。
很多php新手在开发自己的网站采集功能时都会直接用到file_get_contents来读取或fopen是吧,是吧,我们下载采集功能加强了了一点点就是要对方的防盗链都不能防止的采集功能。
function retrieveurlcontentbysocket($url,
$host=,
$port=80,
$timeout=30){
if($host == ){
if(!($pos = strpos($url,'://'))){
return false;
}
$host = substr( $url,
$pos+3,
strpos($url,'/',$pos+3) - $pos - 3);
$uri = substr($url,strpos($url,'/',$pos+3));
}
else{
$uri = $url;
}
$request = get .$uri. http/1.0rn
.host: .$host.rn
.accept: */*rn
.user-agent: zealgetrn
.rn;
$shnd = @fsockopen ($host, $port, $errno, $errstr, $timeout);
if(!$shnd){
return false;
}
@fputs ($shnd, $request);
// get source
$result = ;
while (!feof($shnd)){
$result .= fgets($shnd,4096);
}
fclose($shnd);
$headerend = strpos($result,rnrn);
if (is_bool($headerend))
{
return $result;
}
else{
return substr($result,$headerend+4);
}
http://www.bkjia.com/phpjc/445057.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/445057.htmltecharticle很多php新手在开发自己的网站采集功能时都会直接用到file_get_contents来读取或fopen是吧,是吧,我们下载采集功能加强了了一点点就是要对方...