Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá, preciso de um script para pegar o conteúdo de um site, o site é esse:
http://www.tibia.com/community/?subtopic=characters&name=Awesome+Kaluza
Preciso dos seguintes dados:
Character Deaths
Jul 20 2011, 15:24:25 CEST - Crushed at Level 341 by Don Lenardo, Great Marcin, Korgan Bloodly Blade, Meelro, Qirel, Rogatos Irox, Ronaldo Edek, Sajanowsky, Thunderstorm Knight and Vidakey.
Assisted by Janiszka Knight and Necromanto.
Jul 20 2011, 15:10:21 CEST - Slain at Level 341 by Awesome Kaluza, Izaczek, Kruchyy, Meelro, Necromanto and Thunderstorm Knight.
Assisted by Axel Lou, Don Lenardo, Sir Gimli, Sofiea and Zeid Maxi.
Jul 13 2011, 22:26:28 CEST - Died at Level 339 by a lizard high guard.
Se possível quero a data separada dos dados da morte, por exemplo:
Array
(
[data1] => Jul 20 2011, 15:24:25 CEST
[morte1] => Crushed at Level 341 by Don Lenardo, Great Marcin, Korgan Bloodly Blade, Meelro, Qirel, Rogatos Irox, Ronaldo Edek, Sajanowsky, Thunderstorm Knight and Vidakey. Assisted by Janiszka Knight and Necromanto.
[data2] => Jul 20 2011, 15:10:21 CEST
[morte2] => Slain at Level 341 by Awesome Kaluza, Izaczek, Kruchyy, Meelro, Necromanto and Thunderstorm Knight. Assisted by Axel Lou, Don Lenardo, Sir Gimli, Sofiea and Zeid Maxi.
[data3] => Jul 13 2011, 22:26:28 CEST
[morte3] => Died at Level 339 by a lizard high guard.
)
Tentei desse jeito, mas não consegui separar as tabelas, todos os dados estão juntos e não consigo separar eles em array:
$url = 'http://www.tibia.com/community/?subtopic=characters&name=Awesome+Kaluza';
$site = file_get_contents($url);
$data1 = explode('<b>Character Deaths</b>', $site);
$data2 = explode('</table>',$data1[1]);
$data = $data2[0];
echo $data;
Obrigado desde já! :)
Dei uma pesquisada aqui no fórum mesmo e achei mais fácil fazer por DOMDocument do que por preg_match_all, então consegui resolver!
Código funcionando: