您的位置:首页 > Web前端 > HTML

php读取html并截取字符串的简单代码

2009-11-30 00:00 726 查看
<?php 
$title='脚本之家'; 
$hello='jb51.net!'; 
$file=file_get_contents('http://www.baidu.com'); 
$file=iconv("gbk//IGNORE","utf-8",$file); 
//echo $file; 
echo strpos($file,'<title>'); 
echo substr($file,strpos($file,'<title>')+7,strpos($file,'</title>'-strpos($file,'<title>')+7)); 
$file=str_replace(array('百度一下','{hello}'),array($title,$hello), $file); 
?>

下面是渝海用的小偷程序代码。大家可以多看下。脚本之家提供多款小偷程序。
<?php 
function _url($Date){ 
    $ch = curl_init(); 
    $timeout = 5; 
    curl_setopt ($ch, CURLOPT_URL, "$Date"); 
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); 
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
    $contents = curl_exec($ch); 
    curl_close($ch); 
    return $contents; 
} 
$url="http://www.jb51.net"; 
$contents.=_url($url); 
echo $contents; //输出内容 
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: