Normal way of extracting urls from web-page (not recommended) |
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 />';
}
}
?>
Reffered: https://www.codexworld.com/extract-all-urls-from-web-page-using-php/
php url |
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 |
Read Full: | PHP Extract Tutorial |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | PHP Extract Tutorial |
Uploaded: | 2 weeks ago |
Uploaded by: | Admin |
Views: | 45 |
Tested on: | PHP 7.4 |