etrader Posted January 26, 2011 Share Posted January 26, 2011 I tried to parse wikipedia xml api by different methods, but I was unsuccessful :'( Even the curl method did not work $url = "http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Wikipedia&rvprop=timestamp|content"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTPGET, TRUE); curl_setopt($ch, CURLOPT_POST, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_NOBODY, FALSE); curl_setopt($ch, CURLOPT_VERBOSE, FALSE); curl_setopt($ch, CURLOPT_REFERER, ""); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_MAXREDIRS, 4); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; he; rv:1.9.2. Gecko/20100722 Firefox/3.6.8"); $page = curl_exec($ch); $xml = simplexml_load_string($page); print_r($xml); Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted January 26, 2011 Share Posted January 26, 2011 You need to add "format=xml" to your api query. The wikipedia api default format is xmlfm which is actually just an html representation of the xml, rather than the xml itself. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.