PHP Links Extractor
To easily extract links from URL...
php-links-extractor.php
<?php
$link = "https://www.ludo.one"; // edit here
$content = file_get_contents($link);
$dom = new DOMDocument('1.0');
@$dom->loadHTML($content);
$anchors = $dom->getElementsByTagName('a');
$domaine = explode("/",$link);
$liens = array();
$rliens = "";
$hliens = "";
foreach ($anchors as $element) {
$href = $element->getAttribute('href');
if (0 === strpos($href, 'http')) {
$linkb = explode("/",$href);
if($linkb[2] !== $domaine[2]){
$liens[]= $href;
}
}
}
$rlink = array_unique($liens);
for($i=0;$i<count($rlink);$i++){
if($lineContent !== ""){
if($i===0){
$rliens .= $rlink[$i];
$hliens .= $rlink[$i];
}
else{
$rliens .= "\n".$rlink[$i];
$hliens .= "<br>".$rlink[$i];
}
}
}
file_put_contents("urls-".$domaine[2].".txt", $rliens);
$hliens = preg_replace("/<br><br><br><br>/","<br>",$hliens);
$hliens = preg_replace("/<br><br><br>/","<br>",$hliens);
$hliens = preg_replace("/<br><br>/","<br>",$hliens);
$hliens = preg_replace("/<br><br>/","<br>",$hliens);
echo preg_replace("/<br><br>/","<br>",$hliens);?>