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

yipeiwu_com6年前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语言。我们对PHP还是比较熟悉的,接下来我们将会为大家介绍一下PHP递归算法。PHP,一个嵌套的缩写名称,是英文超级文本预处理语言(PH...

分享一则PHP定义函数代码

先贴代码 复制代码 代码如下: <?php     function table(){     &nb...

PHP使用正则表达式获取微博中的话题和对象名

本文实例讲述了PHP使用正则表达式获取微博中的话题和对象名的方法。分享给大家供大家参考。具体实现方法如下: $post_content = "@jb51和@twitter在研究用#P...

jquery不支持toggle()高(新)版本的问题解决

在js代码中引入以下代码,让高版本的jquery兼容toggle事件。代码如下: /** * Replacement for toggle */ jQuery.fn.toggle...

php 应用程序安全防范技术研究

php 应用程序安全防范技术研究

PHP安全防范程序模型 复制代码 代码如下:   /* PHP防注入跨站V1.0   在您的页面顶部添加: require(“menzhi_injection.php”);   即可实现...