解析php通过cookies获取远程网页的指定代码

yipeiwu_com5年前PHP代码库
复制代码 代码如下:

function Steal($url, $post_data = ""){
//$header[] = "Accept: text/vnd.wap.wml,*.*";  
$user_agent = "Mozilla/4.0"; 
$follow_loc = 1; 
$cookie_file ="./tmp/cook.txt"; 
$ch = @curl_init(); 
@curl_setopt($ch, CURLOPT_URL, $url); 
@curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); 
@curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); 
@curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); 
@curl_setopt($ch, CURLOPT_HEADER, $header); 
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $follow_loc); 
@curl_setopt($ch, CURLOPT_TIMEOUT, 1000); 
if (trim($post_data)!= "") { 
@curl_setopt($ch, CURLOPT_POST, 1); 
@curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 

$result = @curl_exec($ch); 
@curl_close($ch); 
return $result; 
}
//获取网页代码的方法
function Cut($file,$from,$end){
$message=explode($from,$file);
  $message=explode($end,$message[1]);
if ($message[0] == "")
{
$message[0] = "<font color= '#ff0000'>无法获取内容</font>";
}
  return $message[0];
}
//截取代码的方法

相关文章

php中的依赖注入实例详解

本文实例讲述了php中的依赖注入。分享给大家供大家参考,具体如下: 依赖注入是一种允许我们从硬编码的依赖中解耦出来,从而在运行时或者编译时能够修改的软件设计模式。 我到现在依然不大明...

phpMyAdmin通过密码漏洞留后门文件

phpMyAdmin通过密码漏洞留后门文件

默认 phpMyAdmin:用户名 root 密码 root 或空登陆。 版本 2.11.3~2.11.4:用户名 'localhost'@'@" 登陆,无需密码。 版本...

php实现过滤字符串中的中文和数字实例

本文实例讲述了php实现过滤字符串中的中文和数字。分享给大家供大家参考。具体实现方法如下: function getChinese($string,$encode="GBK") {...

Ajax PHP简单入门教程代码

首先我们来了解怎么在javascrīpt中创建这个对象: var xmlHttp = new XMLHttpRequest(); 这行简单的代码在...

解析thinkphp中的M()与D()方法的区别

D()和M()方法的区别:D和M的区别主要在于M方法不需要创建模型类文件,M方法不会读取模型类,所以默认情况下自动验证是无效的,但是可以通过动态赋值的方式实现而D方法必须有创建模型类。我...