Jump to content

get url from a webpage


maddali

Recommended Posts

<?php

$tem=$_SERVER['REQUEST_URI'];

echo "$tem";

$file=file_get_contents("$tem");

 

preg_match("/<div class=\"element-text\">http:\/\/([a-z0-9\/\.]*)<\/div>/i",$file,$matches);

 

$temp=$matches[0];

echo $temp;

 

I'm trying to write a code that takes the current url and get the url link in that webpage.I'm sure I went wrong somewhere in the line 4,where file_get_contents should accept the current url of $tem.Can somebody correct the code please

 

Thanks

Access it like pagename.php?url=http://omars.gmu.edu/items/show/2536

 

<?php

$url = strip_tags($_GET['url']);

if(isset($url)){
$file = file_get_contents($url);

preg_match("/<div class=\"element-text\">http:\/\/([a-z0-9\/\.]*)<\/div>/i", $file, $matches);

echo $matches[0];

}
?>

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.