Skip to content

Instantly share code, notes, and snippets.

@JahsonKim
Created August 10, 2016 08:50
Show Gist options
  • Save JahsonKim/73ff601cbf23464a6395a042c19741e5 to your computer and use it in GitHub Desktop.
Save JahsonKim/73ff601cbf23464a6395a042c19741e5 to your computer and use it in GitHub Desktop.
<?php
include_once('simple_html_dom.php');
$html = new simple_html_dom();
if(isset($_POST['crawl'])){
$crawl = $_POST['target'];
$find = "http://";
//Change "http://" to https// if you are crawling a an https site otherwise keep it http
if(strpos($crawl,$find)!==false){
$html->load_file($crawl);
foreach($html->find('a') as $link)
{
if(strpos($link,"$crawl")!==false){
echo "<p class='links'>".$link->href."</p>";
}
else if(strpos($link,"http://")!==false || strpos($link,"https://")!==false){
echo "<p class='links'>".$link->href."</p>";
}
else{
echo "<p class='links'>"."$crawl/".$link->href."</p>";
}
}
}
else{
echo "Invalid URL";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment