日期:2014-05-17 浏览次数:20576 次
header("Content-type: text/html; charset=gb2312");
require dirname(__FILE__) . '/simple_html_dom.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://news.163.com/12/0613/20/83TJ7PA700014JB6.html');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
$htmls = curl_exec($ch);
curl_close($ch);
$html = str_get_html($htmls);
foreach($html->find('#h1title') as $title){
echo strip_tags($title).'<br />';//标题
}
foreach($html->find('#endText') as $content){
echo strip_tags($content);//正文
}
------解决方案--------------------
PHP获取QQ邮箱好友列表的方法:
------解决方案--------------------
用抓取页面就可以,标题的话就是title标签之间的,正文是body之间的,用正则去掉一些不需要的内容