Jump to content

How do i pull the information from a website's stats page and then display it on another site?


Dobakat

Recommended Posts

I want to pull the information from a website's stats page without having access to that particular database, and then display it on another site, but I am not sure how. Could someone walk me through?
Well the stats page is:
[a href=\"http://www.tibia.com/community/?subtopic=character&name=Dobakat\" target=\"_blank\"]http://www.tibia.com/community/?subtopic=c...er&name=Dobakat[/a]
And my page is:
[a href=\"http://www.istariguild.com/members.php\" target=\"_blank\"]http://www.istariguild.com/members.php[/a]
This is what I got of code:

[code]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Istari Guild</title>
<link rel="STYLESHEET" href="style.css" type="text/css">
<style type="text/css">
<!--
.style1 {
font-size: 28px;
color: FFBA27;
}
.style3 {color: #666666}
-->
</style></head>
<body bgcolor="FFFFFF">
<div align="center">
<table width="750" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" width="750">
<table width="750" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="750" colspan="3"><span class="style1">Istari Guild </span></td>
</tr>
<tr>
<td width="330">&quot;Together we stand, together we die!&quot; </td>
<td width="400" align="right">
<table width="400" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="right" height="20">
<FORM ACTION="http://www.tibia.com/community/?subtopic=character" METHOD=post>
<span class="style3">Search for Character</span>
<INPUT NAME="name" VALUE=""SIZE=20 MAXLENGTH=29>
<input name="Submit" type="submit" value="Search">
</FORM>

</tr>
</table>
</td>
<td width="20"></td>
</tr>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td colspan="3" height="1" bgcolor="CCCCCC"></td>
</tr>
<tr>
<td colspan="3" height="10" bgcolor="FFFFFF"></td>
</tr>
<tr>
<td width="170" bgcolor="FFFFFF" valign="top">
<span style="font-size:6px"><br></span>
<div align="center">
<table width="140" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><?php
include($_SERVER['DOCUMENT_ROOT'].'/menu.php');
?></td>
</tr>
</table>
<br><span style="font-size:6px"><br></span>
<table width="140" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" height="1" bgcolor="AAAAAA"></td>
</tr>
<tr>
<td width="1" bgcolor="AAAAAA" rowspan="5"></td>
<td width="138" height="26" bgcolor="F9F9F9" style="color:FFBA27;font-size:14px">
<div align="center">&nbsp;Announcements
</div></td>
<td width="1" bgcolor="AAAAAA" rowspan="5"></td>
</tr>
<tr>
<td height="1" bgcolor="AAAAAA"></td>
</tr>
<tr>
<td bgcolor="FFFFFF">
<table width="138" border="0" cellpadding="7" cellspacing="0">
<tr>
<td style="color:#666666"><div align="left">
<?php
include($_SERVER['DOCUMENT_ROOT'].'/announcements.php');
?>
</div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1" bgcolor="AAAAAA"></td>
</tr>
</table>
<span style="font-size:6px"><br></span>
</div>
</td>
<td width="1" bgcolor="CCCCCC"></td>
<td width="579" valign="top">
<span style="font-size:6px"><br></span>
<div align="center">
<table width="549" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="4" height="1" bgcolor="AAAAAA"></td>
<td width="5" height="1" bgcolor="FFFFFF"></td>
</tr>
<tr>
<td width="1" bgcolor="AAAAAA"></td>
<td rowspan="2" colspan="2" width="542" height="27" bgcolor="F9F9F9" style="color:FFBA27;font-size:15px">&nbsp;&nbsp;Member List </td>
<td width="1" bgcolor="AAAAAA"></td>
<td width="5" height="4" bgcolor="FFFFFF"></td>
</tr>
<tr>
<td width="1" bgcolor="AAAAAA"></td>
<td width="1" bgcolor="AAAAAA"></td>
<td width="5" bgcolor="F0F0F0" height="23"></td>
</tr>
<tr>
<td width="1" bgcolor="AAAAAA"></td>
<td colspan="2" height="1" bgcolor="AAAAAA"></td>
<td width="1" bgcolor="AAAAAA"></td>
<td width="5" bgcolor="F0F0F0"></td>
</tr>
<tr>
<td width="1" height="206" bgcolor="AAAAAA"></td>
<td colspan="2" bgcolor="FFFFFF">
<table width="542" border="0" cellpadding="17" cellspacing="0">
<tr>
<td style="color:#666666;line-height:1.6em">
<div align="center">
<?php
$world = "Trimera";
$guildname = "Istari";


$path = "http://www.tibia.com/statistics/?subtopic=whoisonline&world=".urlencode($world);
if ($contents = file_get_contents($path)) {



$members = file_get_contents('http://www.tibia.com/community/?subtopic=guilds&page=view&GuildName='.urlencode($guildname)); // get the members file
$members = split("<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>\s|\S*</TABLE>",$members); // get the big parts
$members = strip_tags($members[8],'<tr>'); //take the members element
$members = preg_replace('!<TR BGCOLOR=#w{6,6}|</TR>!','',$members);
$members = str_replace(' ',' ',$members); //Replace HTML entity with normal space.
$members = explode('>',$members);

unset($members[0],$members[1],$members[2]);

for($count=3;$count<count($members)+3;$count++){
$newmember = explode("\n",$members[$count]); //Split up user info.
if (count($newmember) == 3) {
$name = $newmember[2];
} else {
$name = $newmember[1];
}
$name = explode(" (",$name);
$characterSearch = str_replace(' ',' ',$name[0]); //Recovert space to HTML entity for searching.

$characterSearch = ">".$characterSearch."<";

$inOnline = count($onlineList);
$inOffline = count($offlineList);

if (strpos($contents,$characterSearch)) {
$onlineList[$inOnline] = $name[0];
} else {
$offlineList[$inOffline] = $name[0];
}
}
@reset(sort($onlineList));
@reset(sort($offlineList));
?>


<?
echo "".count($members)." Members in the Guild.";
echo "<table border=1 cellpadding=1>";

echo "<tr>";
echo "<td>";
echo "Name";
echo "<td>";
echo "Vocation";
echo "</td>";
echo "<td>";
echo "Level";
echo "</td>";
echo "<td>";
echo "Status";
echo "</td>";
echo "</tr>";
for ($count=0;$count<count($onlineList);$count++) {
$characterSearch = str_replace(' ',' ',"".$onlineList[$count].""); //Recovert space to HTML entity for searching.

$characterSearch = ">".$characterSearch."<";
$level=$level;

echo "<ul id=\"onlineList\">";
echo "<tr>";
echo "<td>";
echo "<a href=\"http://www.tibia.com/community/?subtopic=character&name=".urlencode($onlineList[$count])."\">".$onlineList[$count]."</a>";
echo "<td>";
echo " ";
echo "</td>";
echo "<td>";
echo "$level";
echo "</td>";
echo "<td>";
echo "Online";
echo "</td>";
echo "</tr>";
}

echo" ";
echo "</ul><ul id=\"offlineList\">";

for ($count=0;$count<count($offlineList);$count++) {
echo "<tr>";
echo "<td>";
echo "<a href=\"http://www.tibia.com/community/?subtopic=character&name=".urlencode($offlineList[$count])."\">".$offlineList[$count]."</a>";
echo "<td>";
echo " ";
echo "</td>";
echo "<td>";
echo " ";
echo "</td>";
echo "<td>";
echo "Offline";
echo "</td>";
echo "</tr>";
}
echo "</ul>";
} else {

echo "<p>Opening ".$path." failed.</p>";
}
echo "</table>";

?>
</div></td></tr>
</table>
</td>
<td width="1" bgcolor="AAAAAA"></td>
<td width="5" bgcolor="F0F0F0"></td>
</tr>
<tr>
<td width="1" bgcolor="AAAAAA"></td>
<td colspan="2" height="1" bgcolor="AAAAAA"></td>
<td width="1" bgcolor="AAAAAA"></td>
<td width="5" bgcolor="F0F0F0"></td>
</tr>
<tr>
<td width="1" height="5" bgcolor="FFFFFF"></td>
<td width="4" height="5" bgcolor="FFFFFF"></td>
<td width="538" height="5" bgcolor="F0F0F0"></td>
<td width="1" height="5" bgcolor="F0F0F0"></td>
<td width="5" height="5" bgcolor="F0F0F0"></td>
</tr>
</table>
<span style="font-size:6px"><br>
</span>
</div>
</td>
</tr>
<tr>
<td colspan="3" height="10" bgcolor="FFFFFF"></td>
</tr>
<tr>
<td colspan="3" height="1" bgcolor="CCCCCC"></td>
</tr>
<tr>
<td colspan="3" height="5" bgcolor="FFFFFF"></td>
</tr>
<tr>
<td colspan="3" bgcolor="FFFFFF" align="right"><p>Copyright © 2006, <strong>Dobakat</strong></a>. All Rights Reserved.<br>
The only official site of Tibia is <strong>www.tibia.com</strong>.<br>
Tibia is a copyright of CipSoft GmbH, 2006.</p>
</td>
</tr>
</table>
</div>
</body>
</html>[/code]
Link to comment
Share on other sites

Well, it's a long way to go...

First, use fopen:
[a href=\"http://www.php.net/manual/en/function.fopen.php\" target=\"_blank\"]http://www.php.net/manual/en/function.fopen.php[/a]
To retrieve the page.

Then, use regex functions:
[a href=\"http://www.php.net/manual/en/ref.pcre.php\" target=\"_blank\"]http://www.php.net/manual/en/ref.pcre.php[/a]
To get what you want from the page.

Then you can output it.
Link to comment
Share on other sites

Well i understood the fopen, but not the other one. I was woundering if I could also do it this way:

[code]          <?php
$data= file_get_contents("http://www.tibia.com/community/?subtopic=character&name=dobakat");
$pattern='level';
if (eregi($pattern,$data,$level))
{
echo $level;
}
  ?>
}[/code]

I ran this code and the output was 'Array ?>'.. I think the problem is that the pattern is wrong, how do I fix it?
Link to comment
Share on other sites

All right then, I uploaded it:
[a href=\"http://rapidshare.de/files/18425011/retriever.php.html\" target=\"_blank\"]http://rapidshare.de/files/18425011/retriever.php.html[/a]
(it sucks when you don't have a server)

Just download it, upload it "as is" and open the page.

EDIT: Just as reminder, there is a setting called "allow_url_fopen", if its set to '0', the code won't work. In this case you can use a workaround; a little more complicated.
Link to comment
Share on other sites

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.