Home >Backend Development >PHP Tutorial >求教一个PHP采撷代码的写法

求教一个PHP采撷代码的写法

WBOY
WBOYOriginal
2016-06-13 11:59:031093browse

求教一个PHP采集代码的写法
请问大婶 如果将一个XML完整的采集到PHP
如:
http://www.cailele.com/static/ssc/newlyopenlist.xml
怎么使用PHP怎么采集后并保证采集输出的与XML完全一致

-


------解决方案--------------------

$ch = curl_init();<br /><br />curl_setopt($ch, CURLOPT_URL, "http://www.cailele.com/static/ssc/newlyopenlist.xml");<br /><br />curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); <br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />$r = curl_exec($ch);<br />curl_close($ch);<br />header("content-type:text/xml");<br />echo $r;

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