php读取html并截取字符串的简单代码
程序员文章站
2023-11-22 16:23:16
复制代码 代码如下:
<?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="//www.jb51.net";
$contents.=_url($url);
echo $contents; //输出内容
?>
复制代码 代码如下:
<?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="//www.jb51.net";
$contents.=_url($url);
echo $contents; //输出内容
?>
上一篇: 浅谈$_FILES数组为空的原因