Need help - Get links from a remote site 05-11-2017, 09:32 PM
#1
Hi,
I'm trying to create a php script based on a example but i'm getting nowhere. The goal is to get all the links from a remote site and print them in the browser page.
A query example will be something like this
http://www.example.com/index.php?url=htt.../index.php
The code i'm using is below:
Also i would like to include a form in the php page and a way to format the result in html. This way if a request is not made directly it shows the form to the user and if the request is direct show a properly formated text
Thanks
I'm trying to create a php script based on a example but i'm getting nowhere. The goal is to get all the links from a remote site and print them in the browser page.
A query example will be something like this
http://www.example.com/index.php?url=htt.../index.php
The code i'm using is below:
Code:
<?php
$url = $_GET["url"]
$html = file_get_contents('$url');
$pattern = '/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i';
preg_match_all($pattern, $html, $matches);
foreach($matches[0] as $urladdress){
print "Links: " . $urladdress . "<br>";
}
?>Also i would like to include a form in the php page and a way to format the result in html. This way if a request is not made directly it shows the form to the user and if the request is direct show a properly formated text
Thanks

![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)