解析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连接Access数据库的注意事项

谈谈PHP连接Access数据库的注意事项

首先需要注意: 安装access 数据库的时候 需要安装与本机系统相互匹配的office版本,win7 64位的系统 ,那么Office也要是64位的 最好装 office2010。。。...

PHP跳转页面的几种实现方法详解

•PHP页面跳转一、header()函数header()函数是PHP中进行页面跳转的一种十分简单的方法。header()函数的主要功能是将HTTP协议标头(header)输出...

php switch语句多个值匹配同一代码块的实现

先说说switch()语句的格式 switch(表达式){ case 匹配1: 当匹配1和表达式匹配成功执行的代码; break; case 匹配2: 当匹配2和表达式匹配成功执行的代码...

详谈PHP中的密码安全性Password Hashing

如果你还在用md5加密,建议看看下方密码加密和验证方式。 先看一个简单的Password Hashing例子: <?php //require 'password....

php时区转换转换函数

复制代码 代码如下:/* * 时区转换 */function toTimeZone($src, $from_tz = 'America/Denver', $to_tz...