Answer the question
In order to leave comments, you need to log in
How to download second level pages of simple_html_dom.php?
Tell me how to download second-level pages from the catalog links using simple_html_dom.php
I took all the links to the flights:
// set_time_limit(10);
require_once 'simple_html_dom.php';
require_once 'curl.php';
$site = 'http://biletyczarterowe.r.pl';
$html = curl_get('http://biletyczarterowe.r.pl');
$dom = str_get_html($html);
foreach($dom->find('table[id=prawyKwadrat] tr td a') as $element) {
$a = $element->href;
$a = $site . htmlspecialchars_decode($a);
// --------------------------------------------------------------
$page = curl_get($a);
$page_dom = str_get_html($page);
file_put_contents(md5($page_dom) . '.html', $page_dom);
}
Answer the question
In order to leave comments, you need to log in
//в теле цикла
$linkPage = file_get_html($element->href);
// и лучше сделать рекурсивно - оформить парсинг страниц как функцию, принимающую html и кинуть этот контент в неё же
//а это для решения вашей задачи
file_put_contents(<хэш имени файла>, $linkPage);
updated
$html = file_get_html('http://biletyczarterowe.r.pl/');
foreach($html->find('table[id] tr td a') as $element) {
$outer_html = file_get_html($element->href);
$file = fopen(md5($outer_html) . '.html', 'w');
fwrite($file, $html);
fclose($file);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question