Jump to content

[SOLVED] Getting information from outside sources?


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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.