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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

?>

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.