欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-06-04 08:50:52
...
复制代码 代码如下:
$title='';
$hello='bitsCN.com!';
$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><br>下面是渝海用的小偷程序代码。大家可以多看下。提供多款小偷程序。<br><u>复制代码</u> 代码如下:<br><?php <BR>function _url($Date){ <br> $ch = curl_init(); <br> $timeout = 5; <br> curl_setopt ($ch, CURLOPT_URL, "$Date"); <br> curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); <br> curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); <br> curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); <br> $contents = curl_exec($ch); <br> curl_close($ch); <br> return $contents; <br>} <br>$url="http://www.bitsCN.com"; <br>$contents.=_url($url); <br>echo $contents; //输出内容 <br>?>
相关标签: php 截取字符串