php page file_get_contents http www fes-shop ru catalogue blesnyi-BLUE

 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
41
42
43
44
45
46
47
<?php
$page = file_get_contents('http://www.fes-shop.ru/catalogue/blesnyi-BLUE-FOX/');
preg_match_all("|<div class='nivoCaption'>(.*)</div>|Uis", $page, $name);
preg_match_all("|<img src='./catalog2/(.*)' border='0' width='80'>|Uis", $page, $img);
preg_match_all("|<td valign=top align=right>(.*)</td>|Uis", $page, $price);
preg_match_all("|<input type='hidden' name='id' value='(.*)'>(.*)<input type='hidden' name='way' value='(.*)'>|Uis", $page, $artikul);
$count = count($name['1']);
for($i = 0; $i < $count; ++$i){
$name[1][$i] = iconv("windows-1251", "UTF-8", $name[1][$i]);
$artikul[1][$i] = iconv("windows-1251", "UTF-8", $artikul[1][$i]);
$price[1][$i] = iconv("windows-1251", "UTF-8", $price[1][$i]);
$img[1][$i] = iconv("windows-1251", "UTF-8", $img[1][$i]);
echo $artikul[1][$i].' - '.$name[1][$i].' - '.$img[1][$i].' - '.$price[1][$i].'<br/>';
//$_product = $DBH -> prepare('SELECT * FROM `products` WHERE `id` = ?');
//$_product -> execute(array($sys->xss($_GET['product'])));
//$product = $_product -> fetch();
//$_info = $DBH -> prepare('SELECT * FROM `products` WHERE `name` = ? AND `artikul` = ? AND `img` = ? AND `price` = ? LIMIT 1');
//$_info -> execute(array($name[1][$i],$artikul[1][$i],$img[1][$i],$price[1][$i]));
//$info = $_info -> fetch();
if(!$info){
//$_lyl = $DBH -> prepare('INSERT INTO `products` SET `name` = ?, `opis` = ?, `artikul` = ?, `img` = ?, `price` = ?, `category` = ?');
//$_lyl -> execute(array($name[1][$i],$name[1][$i],$artikul[1][$i],$img[1][$i],$price[1][$i],52));
}
$url = 'http://www.fes-shop.ru/catalog/'.$img[1][$i];
$path = 'img/products/'.$img[1][$i];
if (!file_exists($path)) {
file_put_contents($path, file_get_contents($url));
}
}
foreach ($out['1'] as $value) {
echo $value.'<br/>';
}
foreach ($out2['1'] as $value) {
echo '<img border="0" width="80" src="http://www.fes-shop.ru/catalog/'.$value.'"><br/>';
}
foreach ($out3['1'] as $value) {
echo $value.'<br/>';
}
foreach ($out4['2'] as $value) {
echo $value.'<br/>';
}