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" Link to comment https://forums.phpfreaks.com/topic/223986-getting-certain-content-from-another-webpage/ 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. Link to comment https://forums.phpfreaks.com/topic/223986-getting-certain-content-from-another-webpage/#findComment-1157519 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); } } Link to comment https://forums.phpfreaks.com/topic/223986-getting-certain-content-from-another-webpage/#findComment-1157529 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.