日期:2014-05-17  浏览次数:20419 次

curl的一些小问题
请教一下把一个网页的某部分内容抓取出来是怎么实现的...没有思路....
比如说我想抓取mmcfood.1x.net里面的表格...其他的都不要..

------解决方案--------------------
PHP code
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://mmcfood.1x.net/');
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);
preg_match("#<table width=\"1079\" ([^>]*)>(.*?)</table>#is", $htmls, $matches);
echo $matches[0];