When I do one website at once it works just fine but when I do more at a time I get the following error:
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Host is onbekend. in C:\xampp\htdocs\blabla\simple_html_dom.php on line 76
Warning: file_get_contents(https://www.google.nl ): failed to open stream: php_network_getaddresses: getaddrinfo failed: Host is onbekend. in C:\xampp\htdocs\blabla\simple_html_dom.php on line 76
Fatal error: Call to a member function find() on a non-object in C:\xampp\htdocs\blabla\backend.php on line 21
This is my image scraper:
<?php
if (isset($_POST["submit"])) {
$notes = explode("\n", $_POST['linkjes']);
foreach ($notes as $link) {
x($link);
}
}
else
{
echo "je hoort hier niet";
}
function x($link){
$file = 'images.txt';
$current = file_get_contents($file);
include_once 'simple_html_dom.php';
$html = file_get_html($link);
foreach($html->find('img') as $element)
if (strpos($element->src,'.png') !== false)
{
$current .= $element->src."\n";
file_put_contents($file, $current);
}
else if (strpos($element->src,'.jpg') !== false)
{
$current .= $element->src."\n";
file_put_contents($file, $current);
}
else if (strpos($element->src,'.gif') !== false)
{
$current .= $element->src."\n";
file_put_contents($file, $current);
}
else if (strpos($element->src,'.ico') !== false)
{
$current .= $element->src."\n";
file_put_contents($file, $current);
}
else if (strpos($element->src,'.jpeg') !== false)
{
$current .= $element->src."\n";
file_put_contents($file, $current);
}
$lines = file($file);
$lines = array_unique($lines);
file_put_contents($file, implode($lines));
}
?>