网络编程 
首页 > 网络编程 > 浏览文章

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

(编辑:jimmy 日期: 2024/5/10 浏览:3 次 )

复制代码 代码如下:
<?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="https://www.jb51.net";
$contents.=_url($url);
echo $contents; //输出内容
?>

上一篇:PHP MYSQL乱码问题,使用SET NAMES utf8校正
下一篇:php 获取客户端的真实ip
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网