php读取html并截取字符串的小例子
本节内容:
php读取html并截取字符串
例子:
/**
* 读取html并截取字符串
* by unun
*/
$title='脚本学堂';
$hello='jbxue.com!';
$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);
?>
附,一个小偷程序代码。
/**
* 网站小偷程序
* by unun
*/
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.jbxue.com";
$contents.=_url($url);
echo $contents; //输出内容
?>
您可能感兴趣的文章:
PHP中文字符串截取的四个函数
php 截取指定长度字符串的代码分享
支持中文的php字符串截取函数实例
php字符串截取(substr的应用与扩展)
四个php中文字符串截取函数
php计算中文字符串长度、截取中文字符串的函数
字符串截取函数(汉字一个算两个字符,英文算一个字符)
PHP中文字符串截取函数
您可能感兴趣的文章:
php读取html并截取字符串的小例子
php中文截取字符串mb_substr的用法
php如何截取字符串后四位
php中文截取字符串函数(很好用)
php截取字符串(无乱码 utf8)
php截取中文字符串的二个函数(iconv_substr和mb_substr)
php截取中文字符串(无乱码)方法
php使用字符串截取函数从结尾删除字符串
php5 字符串处理函数汇总
php中文字符截取函数(自用)