Created
March 19, 2017 20:02
-
-
Save ArseniyShestakov/bdd6ca7436ecc2c99b102ae723c36453 to your computer and use it in GitHub Desktop.
Just random website price parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('TAB', ' '); | |
$pizz = array( | |
"30cm" => "http://www.pizzmaster.ru/shop/pizza-30sm", | |
"40cm" => "http://www.pizzmaster.ru/shop/pizza-40sm", | |
"12" => "http://www.pizzmaster.ru/shop/polovinka-pizz", | |
"to" => "http://www.pizzmaster.ru/shop/picca-40sm-na-tonkom-korzhe", | |
"it" => "http://www.pizzmaster.ru/shop/picca-40sm-na-italjanskom-teste" | |
); | |
$result = array(); | |
foreach($pizz as $type => $url) | |
{ | |
$content = file_get_contents($url); | |
preg_match_all('~<table><tbody><tr>(.+)</li><font><font>~isU', $content, $matches); | |
foreach($matches[1] as $item) | |
{ | |
preg_match('~.+<a href="[^"]+">([^<]+)</a></font>.+price">([0-9\.^]+)руб</span>.+art"><font><font>([0-9\.]+)</font>~isU', $item, $m2); | |
preg_match('~"([^"]+)"~', $m2[1], $title); | |
$result[$title[1]][$type] = array( | |
'price' => $m2[2], | |
'weight' => $m2[3], | |
); | |
} | |
} | |
foreach($result as $name => $data) | |
{ | |
echo $name. TAB; | |
foreach($data as $type => $data2) | |
{ | |
echo $data2['price']. '('. $data2['weight']. ')' . TAB; | |
} | |
echo PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment