DEV Community

pikasho
pikasho

Posted on

Scrape all images 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 images the Spotiflyer.

PHP Code
`<?php

// Initialize curl
$ch = curl_init();

// URL for Scraping
curl_setopt($ch, CURLOPT_URL,
'https://spotiflyer.online/matlab-data-types/');

// Return Transfer True
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec($ch);

// Closing cURL
curl_close($ch);

// For web page display
echo '

';
echo ' content="text/html; charset=utf-8" />';
echo '';
echo '';

echo '

Web Scraping using cURL

';

// Checking for images
preg_match_all(
'!https://spotiflyer.online/wp-content/uploads/(.*)/(.*).png!',
$output, $data
);

foreach ($data[0] as $list) {
echo "";
}

echo '';

?>`

Top comments (0)