Je souhaiterais utiliser PHP-8 Parallel (https://github.com/krakjoe/parallel. Ou encore: https://php.net/parallel) dans ma fonction follow_links:
Code : Tout sélectionner
function followLinks($urls) {
global $alreadyCrawled;
global $crawling;
$parser = new DomDocumentParser($page);
foreach($urls as $page) {
$linkList = $parser->getLinks();
foreach($linkList as $link) {
$href = $link->getAttribute("href");
if(strpos($href, "#") !== false) {
continue;
}
else if(substr($href, 0, 11) == "javascript:") {
continue;
}
$href = createLink($href, $url);
if(!in_array($href, $alreadyCrawled)) {
$alreadyCrawled[] = $href;
$crawling[] = $href;
// Output the page title, descriptions, keywords, URL, Image, Video, etc... This output is
// piped off to an external file using the command line.
getDetails($href);
}
}
}
// Remove an item from the array after we have crawled it.
// This prevents infinitely crawling the same page.
array_shift($crawling);
followLinks($crawling);
}
$starts = ["https://website1.dn", "https://website2.dn", "https://website3.dn", "https://website4.dn"];
followLinks($starts);Merci de m'aider.