Created
March 19, 2018 23:37
-
-
Save txj-xyz/3f18177189e7e733c1448157bcb782f6 to your computer and use it in GitHub Desktop.
Grabs all links from a URL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors', 'Off'); | |
$string = file_get_contents($_POST['requestURL']); | |
$regex = '/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i'; | |
preg_match_all($regex, $string, $matches); | |
$urls = $matches[0]; | |
// go over all links | |
foreach($urls as $url) | |
{ | |
echo "<a href='" . $url."'<br />". $url."<br />";; | |
} | |
?> | |
</br> | |
<center> | |
Please enter the URL you wish to grab links from | |
<form method="post" action=""> | |
<input type="text" name="requestURL"> | |
<input type="submit" value="request_now"> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you