php set_time_limit include parser php include notebook php function ge

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
set_time_limit(0);
include('parser.php');
include('notebook.php');
function getTotalPagesCount($page_url) {
$parser = new Curl;
$page = $parser->get($page_url);
preg_match('/p=\d+\">(.+)<\/a>\s+<\/span>/', $page, $pages_count);
unset($parser);
return $pages_count;
}
$total_pages_count = getTotalPagesCount('http://hotline.ua/computer/noutbuki-netbuki/?sort=4');
$pages_needed_to_be_parsed = round(500 / 24); //21. We hope, that we'll have 24 notebooks per page, but better to check this
if ($pages_needed_to_be_parsed > $total_pages_count) $pages_needed_to_be_parsed = $total_pages_count;
for ($i = 0; $i <= $until; $i++) {
$parser = new Curl;
$page = $parser->get('http://hotline.ua/computer/noutbuki-netbuki/?sort=4&p=' . $i);
preg_match_all('/<h3><a .+\}\);\">(.+)<\/a>/', $page, $name_matches);
preg_match_all('/\'tech\-char\'>(.+)<\/span>/', $page, $prop_matches);
$string = '';
for ($a = 0; $a <= 24; $a++) {
$notebook = new Notebook;
$notebook->parse_from_html($prop_matches[1][$a]);
$string .= 24 * $i + $a + 1 . '. '; //number of item
$string .= $name_matches[1][$a] . '<br/>' . $notebook->get_html_result() . '<br/>';
}
file_put_contents('popular_notebooks.html', $string, FILE_APPEND);
unset($hotline);
}