Jump to content

[SOLVED] Getting information from outside sources?


al3x8730

Recommended Posts

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.

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?

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();.

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.

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);
?>

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.

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";
}

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?

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.