Simple way extracts all url from a single page link with PHP |
Example:
PHP
<?php
$urlContent = file_get_contents('http://php.net');
$dom = new DOMDocument();
@$dom->loadHTML($urlContent);
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");
for($i = 0; $i < $hrefs->length; $i++){
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
$url = filter_var($url, FILTER_SANITIZE_URL);
// validate url
if(!filter_var($url, FILTER_VALIDATE_URL) === false){
echo '<a href="'.$url.'">'.$url.'</a><br />';
}
}
?>
How to extract Domain Name from Full URL in PHP | PHP Extract Tutorial |
How to extract only name from domain in PHP | PHP Extract Tutorial |
How to extract All url from a single page by PHP | PHP Extract Tutorial |
How to get first Five Line from CSV File | PHP Extract Tutorial |
How to get first 100 records from a csv file in PHP | PHP Extract Tutorial |
How to get meta Tag | PHP Extract Tutorial |
How to get title description image and multiple images from URL | PHP Extract Tutorial |
How to read a txt file from a zip remote URL | PHP Extract Tutorial |
How to extract all url from a html single page in PHP | PHP Extract Tutorial |
Completed PHP Extracting Code | PHP Extract Tutorial |
A Demo Screenshot in output area | PHP Extract Tutorial |
Read Full: | PHP Extract Tutorial |
Category: | Web Tutorial |
Sub Category: | PHP Extract Tutorial |
Uploaded: | 1 year ago |
Uploaded by: | Admin |
Views: | 44 |