nimedon Posted June 7, 2007 Share Posted June 7, 2007 Hi, is there anyway to copy a part of another webpage to show in my page, for example copy the statics of the following webpage: http://otservlist.org/ and the statics are here: <td> <fieldset><legend> Servers statistics </legend> We have <strong>6743</strong> servers in our database<br /> Current Time: June 7, 2007, 6:01 am </fieldset> </td> but I want to refresh them, how can I do this? thanks in advance, Nimedon Quote Link to comment Share on other sites More sharing options...
trq Posted June 7, 2007 Share Posted June 7, 2007 Take a look at file_get_contents(). Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 7, 2007 Share Posted June 7, 2007 @nimedon And while you're at it - also take a look at the copyright at the bottom of the page you linked to. They don't put it there "for fun" you know. An honorable person would at least ask permission and include a "Provided By" message on the page with a link back to the source. Quote Link to comment Share on other sites More sharing options...
nimedon Posted June 7, 2007 Author Share Posted June 7, 2007 @mjdamato: I will, I hate persons that quit credits Quote Link to comment Share on other sites More sharing options...
nimedon Posted June 7, 2007 Author Share Posted June 7, 2007 I taked a look at that function, but I can't get it work, can anyone give me an example or somthing? Quote Link to comment Share on other sites More sharing options...
chigley Posted June 7, 2007 Share Posted June 7, 2007 <?php $pagesource = file_get_contents("http://www.otservlist.org"); echo $pagesource; ?> Quote Link to comment Share on other sites More sharing options...
nimedon Posted June 7, 2007 Author Share Posted June 7, 2007 but, it prints the whole page, how can I do to just print a part? Quote Link to comment Share on other sites More sharing options...
chigley Posted June 7, 2007 Share Posted June 7, 2007 Depends which part of it you want! You need to parse the data you have Quote Link to comment Share on other sites More sharing options...
nimedon Posted June 7, 2007 Author Share Posted June 7, 2007 I want to print the part of Server Statics, how do I parse the data? Quote Link to comment Share on other sites More sharing options...
chigley Posted June 7, 2007 Share Posted June 7, 2007 <?php function textbetweenarray($s1,$s2,$s){ $myarray=array(); $s1=strtolower($s1); $s2=strtolower($s2); $L1=strlen($s1); $L2=strlen($s2); $scheck=strtolower($s); do{ $pos1 = strpos($scheck,$s1); if($pos1!==false){ $pos2 = strpos(substr($scheck,$pos1+$L1),$s2); if($pos2!==false){ $myarray[]=substr($s,$pos1+$L1,$pos2); $s=substr($s,$pos1+$L1+$pos2+$L2); $scheck=strtolower($s); } } } while (($pos1!==false)and($pos2!==false)); return $myarray; } $pagesource = file_get_contents("http://www.otservlist.org"); $fieldsets = textbetweenarray("<fieldset>", "</fieldset>", $pagesource); $serverstats = $fieldsets[1]; echo $serverstats; ?> Quote Link to comment Share on other sites More sharing options...
nimedon Posted June 7, 2007 Author Share Posted June 7, 2007 o.0 I love you!!! ty very much!! :* Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.