al3x8730 Posted September 2, 2008 Share Posted September 2, 2008 I'm not sure whatsoever if this is possible, but would it be possible to get information from another page. Say a who's online list, and take them information somehow, and post it on your site? Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/ Share on other sites More sharing options...
BlueSkyIS Posted September 2, 2008 Share Posted September 2, 2008 maybe, depending on what page and how the text is displayed (HTML, javascript, image?) if it's HTML, you could grab the page using curl functions, parse the HTML, and display the content as you like. Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632220 Share on other sites More sharing options...
al3x8730 Posted September 2, 2008 Author Share Posted September 2, 2008 Well, how would I go about getting information from a page like: http://game.endless-online.com/playerlist.html And get something that will take that who's online. Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632239 Share on other sites More sharing options...
DarkWater Posted September 2, 2008 Share Posted September 2, 2008 cURL to grab the file, and regex to parse the content out. Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632243 Share on other sites More sharing options...
al3x8730 Posted September 2, 2008 Author Share Posted September 2, 2008 cURL to grab the file, and regex to parse the content out. Am I going to have to look that up or can you help me? Or is it complicated? I don't know how to do that at all :| Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632248 Share on other sites More sharing options...
DarkWater Posted September 2, 2008 Share Posted September 2, 2008 The cURL is easy, the regex is not. Go to the manual page for cURL and get that working (if you REALLY can't get cURL working, I'll give you some code to start, but it's pretty simple). And then I'll try and help with the regex. Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632250 Share on other sites More sharing options...
al3x8730 Posted September 2, 2008 Author Share Posted September 2, 2008 The cURL is easy, the regex is not. Go to the manual page for cURL and get that working (if you REALLY can't get cURL working, I'll give you some code to start, but it's pretty simple). And then I'll try and help with the regex. Um, which curl function do I use? Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632257 Share on other sites More sharing options...
DarkWater Posted September 2, 2008 Share Posted September 2, 2008 Check out curl_init(), curl_setopt(), and curl_exec(). Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632261 Share on other sites More sharing options...
al3x8730 Posted September 2, 2008 Author Share Posted September 2, 2008 Check out curl_init(), curl_setopt(), and curl_exec(). I'm looking at it... Can you help me out some? I really don't know what to do Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632267 Share on other sites More sharing options...
DarkWater Posted September 2, 2008 Share Posted September 2, 2008 Something like this would suffice: <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://game.endless-online.com/playerlist.html"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $data = curl_exec($ch); ?> Understand it? EDIT: Fixed an error with curl_exec();. Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632275 Share on other sites More sharing options...
al3x8730 Posted September 2, 2008 Author Share Posted September 2, 2008 Something like this would suffice: <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://game.endless-online.com/playerlist.html"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $data = curl_exec(); ?> Understand it? Not really xD I've been going through php tutorials on and off for quite some time. I know a lot of functions, just not that. Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632277 Share on other sites More sharing options...
sasa Posted September 2, 2008 Share Posted September 2, 2008 try <?php $test = file_get_contents('http://game.endless-online.com/playerlist.html'); //echo $test; preg_match_all('|<td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="50"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="100"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="70"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td>|is',$test, $out); print_r($out); ?> Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632295 Share on other sites More sharing options...
al3x8730 Posted September 2, 2008 Author Share Posted September 2, 2008 try <?php $test = file_get_contents('http://game.endless-online.com/playerlist.html'); //echo $test; preg_match_all('|<td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="50"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="100"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="70"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td>|is',$test, $out); print_r($out); ?> Thanks a lot, it works. Accept it's just a bundle of mess. How would I go about sorting it? Into an organized list. Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632302 Share on other sites More sharing options...
sasa Posted September 2, 2008 Share Posted September 2, 2008 in 1st subarray (index0) is all data in 2nd is name then title ,lvl, experience, gardner foreach ($out[0] as $k => $v){ echo 'name: ', $out[1][$k], ', title: ', $out[2][$k], ', lvl ', $out[3][$k], ', experience: ', $out[4][$k], ', gardner: ',$out[5][$k], "<br />\n"; } Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632310 Share on other sites More sharing options...
al3x8730 Posted September 2, 2008 Author Share Posted September 2, 2008 in 1st subarray (index0) is all data in 2nd is name then title ,lvl, experience, gardner foreach ($out[0] as $k => $v){ echo 'name: ', $out[1][$k], ', title: ', $out[2][$k], ', lvl ', $out[3][$k], ', experience: ', $out[4][$k], ', gardner: ',$out[5][$k], "<br />\n"; } Where would I insert that into the script? Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632313 Share on other sites More sharing options...
al3x8730 Posted September 2, 2008 Author Share Posted September 2, 2008 in 1st subarray (index0) is all data in 2nd is name then title ,lvl, experience, gardner foreach ($out[0] as $k => $v){ echo 'name: ', $out[1][$k], ', title: ', $out[2][$k], ', lvl ', $out[3][$k], ', experience: ', $out[4][$k], ', gardner: ',$out[5][$k], "<br />\n"; } Where would I insert that into the script? Nevermind, I got it, thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632318 Share on other sites More sharing options...
natbob Posted September 2, 2008 Share Posted September 2, 2008 $r = new HttpRequest($webpageToGet); $r->send(); $res = $r->getResponseBody(); will also work, it uses the HTTP class/extension Quote Link to comment https://forums.phpfreaks.com/topic/122443-solved-getting-information-from-outside-sources/#findComment-632327 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.