解析php通过cookies获取远程网页的指定代码
2018-10-12 13:53
706 查看
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通过cookies获取远程网页的指定代码
- php通过cookies获取远程网页的指定代码
- asp获取远程网页的指定内容的实现代码
- asp获取远程网页的指定内容的实现代码
- PHP 获取远程网页内容的代码(fopen,curl已测)
- ASP函数 获取域名解析后的IP 获取远程网页的HTML代码
- [PHP代码] PHP远程获取网页内容
- 分享几段获取远程网页内容的php代码。
- PHP 获取远程网页内容的代码(fopen,curl已测)
- PHP下通过file_get_contents\curl的方法实现获取远程网页内容(别忘了还有PhpRPC)
- PHP下通过file_get_contents()方法不能正常获取远程网页内容
- PHP 通过fsockopen函数获取远程网页源码
- asp获取远程网页的指定内容的实现代码
- geoip+php演示样例:通过ip,获取国家名称和代码
- 使用JAVA代码通过SSH访问远程windows,获取磁盘信息
- 解析php多线程下载远程多个文件的实例代码
- C#获取指定网页HTML原代码
- 用php实现的获取网页中的图片并保存到本地的代码