PHP获取url的函数代码

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

function geturl($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
//在需要用户检测的网页里需要增加下面两行
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//curl_setopt($ch, CURLOPT_USERPWD, US_NAME.”:”.US_PWD);
$contents = curl_exec($ch);
curl_close($ch);
$contents = str_replace("document.write('","",$contents);
$contents = str_replace("');","",$contents);
$contents = str_replace("\\n","",$contents);
$contents = str_replace("\\","",$contents);
echo $contents;
}

相关文章

PHP 日,周,月点击排行统计

复制代码 代码如下: $now=time(); //当前时间 $StrUpdate = "Update $tbl_article set hits=hits+1"; if(date("d...

PHP学习散记_编码(json_encode 中文不显示)

在网上找到一种解决方法: 复制代码 代码如下: <?php /* 处理json_encode中文乱码 */ $data = array ('game' => '冰火国度',...

php常用的工具开发整理

php常用的工具开发整理

PHP开发工具及其优缺点 首先,可以用记事本来开发。 记事本每个人的电脑上都有,也就是我们常说的txt文件。把txt这个后缀更改为点PHP就可以了。然后该怎么编辑就怎么编辑。缺点是, 没...

php代码审计比较有意思的例子

php代码审计比较有意思的例子

代码审计比较有意思的例子貌似是去年 ecshop支付漏洞偶然出来的一个例子,感觉不错。分享下 复制代码 代码如下:<?php$a=addslashes($_GET['a']);$b...

php截取视频指定帧为图片

截取视频指定帧为图片,php ffmpeg扩展已经完美实现: $movie = new ffmpeg_movie($video_filePath); $ff_frame = $mov...