smerny Posted January 10, 2011 Share Posted January 10, 2011 I've used get_file_contents() before but it seems like it took a long time to load... what is the best or most efficient way to get certain content from a webpage? Like all the posts on a single forum page for example, without loading any images or styles, just the "source" Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 10, 2011 Share Posted January 10, 2011 file_get_contents() does not load any images or styles, just the source. Quote Link to comment Share on other sites More sharing options...
smerny Posted January 10, 2011 Author Share Posted January 10, 2011 i made this function awhile back... it just seems slow, i guess i'm just curious if theres a faster way function getPrice($n) { $ch = curl_init() or die(curl_error()); curl_setopt($ch, CURLOPT_URL,"http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj=".$n); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $raw=curl_exec($ch) or die(curl_error()); curl_close($ch); $findme = 'Item not found'; $pos = strpos($raw, $findme); if ($pos !== false) { return "Item Not Found"; } else { $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B"); $content = str_replace($newlines, "", html_entity_decode($raw)); $start = strpos($content,'<b>Market price:</b> ')+21; $end = strpos($content,'</span>',$start); $marketValue = substr($content,$start,$end-$start); return myStr2Int($marketValue); } } 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.