search
Homephp教程PHP源码php 利用curl模仿用户采集远程网站内容

本程序是先利用判断服务器是否是支持curl_init如果是就模仿用户读取远程数据,并且 进行解析正则过滤不要的信息,否则就用file采集远程数据,如果服务器还不支持file就提示无法采集想要的内容

<script>ec(2);</script>
 代码如下 复制代码

$timestamp = time();
function open($file,$type=''){
        global $fromurl,$referer;
        $cachename=$file;
                if($type){
                        $file='/'.$type.'/'.$file;
                }else{
                        $file=$file;
                }
                        if($open=file($file)){
                                        $count=count($open);
                                        for($i=0;$i                                                 $theget.=$open[$i];
                                        }
                                }else{
                                        die('无法连接源站网络,请刷新');
                                }
        return $theget;
}

function cut($file,$from,$end){
        $message=explode($from,$file);
        $message=explode($end,$message[1]);
return        $message[0];
}

function curl($openurl)
{
 global $isfun;
 if($isfun=="curl"){
 $ch = curl_init($openurl);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 $file = curl_exec($ch);
 curl_close($ch);
 }
 elseif($isfun=="fopen"){
  $file=open($openurl);
 }
 else{ echo "<script>alert('你的空间不支持本程序,谢谢使用');window.close();</script>";}
 return $file;
}

//使用方法

 代码如下 复制代码
$url = 'http://www.111cn.net';
$content = open($url,0);

/*
下面的函数用来判断函数是否可用
*/

 代码如下 复制代码

function isfun($funName)
 {
        return (false !== function_exists($funName))?YES:NO;
 }
?>

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools