Jump to content

It's posible to copy a part of a web page to show on mine?


nimedon

Recommended Posts

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

@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.

<?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;

?>

Archived

This topic is now archived and is closed to further replies.

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