This repository was archived by the owner on May 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.php
More file actions
40 lines (37 loc) · 1.5 KB
/
parser.php
File metadata and controls
40 lines (37 loc) · 1.5 KB
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
36
37
38
39
40
<?php
/***************************************************************************
* *
* (c) 2012 Sergei Lomakov sergei@lomakov.net *
* *
* This is commercial software, only users who have purchased a valid *
* license and accept to the terms of the License Agreement can install *
* and use this program. *
* *
****************************************************************************
* PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. *
****************************************************************************/
# Source:
$URL = 'http://rossvyaz.ru/docs/articles/DEF-9x.html';
$DB = 'database.sql';
echo "Starting...\n";
$html = file_get_contents($URL);
$defTable = iconv('cp1251', 'utf-8', $html);
$regex = '';
for($i=0; $i<6; $i++) {
$regex .= '<td>(.*?)</td>\s+';
}
$row = array();
preg_match_all("%{$regex}%si", $defTable, $results, PREG_SET_ORDER);
$hFile = fopen($DB, 'w');
if (count($results)) {
foreach($results as $row) {
unset($row[0]);
array_walk($row, function(&$e) {
$e = trim($e);
});
fputcsv($hFile, $row);
}
}
fclose($hFile);
echo "Done\n";