时间:2021-04-18加入收藏
$c = curl_init();
$url = 'www.bingdou.com.cn';
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($c);
curl_close($c);
$pos = strpos($data,'utf-8');
if($pos===false){$data = iconv("gbk","utf-8",$data);}
preg_match("/<title>(.*)<\/title>/i",$data, $stitle);
eregi("</head>(.*)</body>",$data,$sbody);
$title = $stitle[1];//获取标题
$slbody = preg_replace(array("'<style(.*?)>(.*?)</style>'is","'<script(.*?)>(.*?)</script>'is","/<\/?[^>]+>/i"),'',$sbody[1]);//获取纯文本内容