Home >Backend Development >PHP Tutorial > curl的一些小疑点

curl的一些小疑点

WBOY
WBOYOriginal
2016-06-13 13:11:12744browse

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("#
]*)>(.*?)
#is", $htmls, $matches); echo $matches[0];
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn