>  기사  >  백엔드 개발  >  php读取html并截取字符串的简单代码_PHP教程

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

WBOY
WBOY원래의
2016-07-21 15:42:21791검색

复制代码 代码如下:

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

下面是渝海用的小偷程序代码。大家可以多看下。脚本之家提供多款小偷程序。
复制代码 代码如下:

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; //输出内容
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/320996.htmlTechArticle复制代码 代码如下: ?php $title='脚本之家'; $hello='jb51.net!'; $file=file_get_contents('http://www.baidu.com'); $file=iconv("gbk//IGNORE","utf-8",$file); //echo $file;...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.