Gadget With PHp

Is there a way to use .php instead of useing .html

I have a code that I would like to use but its from a php script

$url="www.YourSourceURL.com"; //replace with the full URL you wish to fetch the data from
preg_match("/^(https :\/\/) ([^\/]*)(.*)/i", "$url", $matches);
$domain = "http://" . $matches[2];
$page = $matches[3];
$fd = fopen($domain.$page, "rb");
$code = "";
while(!feof($fd)){
$code .= fread($fd, 4096);
}
fclose($fd);
$start= strpos($code, "START PONT"); // replace with your STARTING POINT source of HTML page
$finish= strpos($code, "END POINT"); // replace with your END POINT source of HTML page
$length= $finish-$start;
$code=substr($code, $start, $length);
$newcode = preg_replace("/(href=\" )(\/[^\"\/]+)/", "\\1" . $domain . "\\2", $code);
echo $newcode;
>



Answer this question

Gadget With PHp

  • Vesigo

    If I'm right, this piece gets some webpage and extracts data from it ...

    You can rebuild this behaviour by using JavaScript and the XMLHttpRequest Object.


  • yoshimitu

    Try the Answer in this thread.

  • keithpsft

    Thomas Li wrote:

    If I'm right, this piece gets some webpage and extracts data from it ...

    You can rebuild this behaviour by using JavaScript and the XMLHttpRequest Object.

    Yes that is what the script does I have tried a few times to get the XMLHttpRequest to work but i am lost when it comes to javaScript a push in the right direction or sample gadget would be great


  • Clemox

    Or if Possible to convert that to regular html
  • Gadget With PHp