最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php采集代码-反防盗链采集
时间:2009-03-04 编辑:简简单单 来源:一聚教程网
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);
}
相关文章
- php防盗链几种代码 06-05
- php下通过伪造http头破解防盗链的代码 07-03
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31