解析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全局使用Laravel辅助函数dd

dump() 方法 全局 composer.json "require": { "squizlabs/php_codesniffer": "*", "fxp/composer...

PHP empty函数报错解决办法

PHP开发时,当你使用empty检查一个函数返回的结果时会报错:Fatal error: Can't use function return value in write context...

修改PHP脚本使WordPress拦截垃圾评论的方法示例

拦截英文垃圾评论 由于绝大多数的垃圾评论都是英文的,所以国内不少朋友在使用 Some Chinese Please 插件,它可以有效地拦截内容中不带有中文字的comment和trackb...

基于PHP安装zip拓展,以及libzip安装的问题

Linux: php要调用\ZipArchive类的时候,需要安装了ZIP拓展库才行,而zip拓展库需要先安装libzip. 我们先下载: wget http://pecl.php.ne...

phpmyadmin 3.4 空密码登录的实现方法

因为我把php升级到了5.3.1,以前的phpmyadmin版本不能用了,就升级到phpMyAdmin 3.2.4版的时候,会遇到无法以空密码登录root用户的情况。怎么解决呢? 请参照...