• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

PHP - Scrap online list

Jockiboi

Banned User
Joined
Oct 12, 2010
Messages
1,156
Reaction score
9
Hiho!

I've now been trying to make a scrapper for online list @ Tibia.com. My code so far looks liek:
PHP:
<?php
error_reporting(E_ALL ^ E_NOTICE);
class tibia {

    private $_worldURL = 'http://www.tibia.com/community/?subtopic=worlds&world=%s';

    public function getPlayerOnlineStatus( $world ) {
        $url = sprintf($this->_worldURL, ucfirst($world));
        $raw = file_get_contents($url);
		$data = null;
		
		if(strpos($raw, 'Players Online') > 0) {
            $data = array();
            $raw = str_replace(array('<br />', ' '), array('', ' '), $raw);
            $raw = preg_replace('/<A HREF="([^>]+)">([^<]+)<\/A>/', '[url=\1]\2[/url]', $raw);
            preg_match_all('/>(Name|Level|Vocation):(?:<\/?[^>]+>){2}([^<]+)/', $raw, $matches);

            for($i = 0, $count = count($matches[0]); $i < $count; $i++) {
                $var = str_replace(' ', '_', strtolower($matches[1][$i]));
                $value = html_entity_decode(trim($matches[2][$i])); //Trim so you wont be needing to remove spaces and save more "clean" strings

                $data[$var] = $value;
            }
        }


        return $data;

    }
}

$tibia = new tibia;

$tibia->getPlayerOnlineStatus('Nova');
if ($data != NULL) {
	echo $data['name'];
} else { echo 'null'; }
?>

resulT= 'null'

helps pls
 
If you run the query through phpMyAdmin, do you get any result?
SQL:
SELECT * FROM online WHERE level >= 1 AND level <= 999 AND vocation = "Master Sorcerer";
 
Nop, I don't.

And by the way; Just noticed that vocations with 2 words (ek, ed, ms, rp) dosen't work, but vocations with one word works. o.O
 
Do you have TeamViewer (remote desktop)? If you do, I would be more than happy to assist you through TV. All you'd have to do is to send me a PM with your TV credentials and I'll be able to login and view (and control if you allow me to) your computer.
 
Back
Top