DEV Community

pikasho
pikasho

Posted on

Scrape any links from websites

First of all you need to download html dom parser file from sourceforge. Then this code will work for you best.
Here is the code you can find all links and text in the Yacine TV.

PHP Code
<?php
include('simplehtmldom/simple_html_dom.php');

// Create DOM from URL or file
$html = file_get_html('https://yacinetv.co');

// Find all links, and their text
foreach($html->find('a') as $elm) {
echo $elm->href .' ('.$elm->plaintext. ')
';
}
?>

Top comments (1)

Collapse
 
margarethiginson profile image
MargaretHiginson

Can you legally scrape websites? wazifa for winning court case