Всем привет! Прошу помощи, использую simple_html_dom.php:
<?
include "simple_html_dom.php";
$dnsdata = fopen("mts.txt", 'r') or die("не удалось открыть файл dns.txt");
while(!feof($dnsdata))
{
$url = fgets($dnsdata);
if ($url == '-')
{
$nm[0] = '-';
$ret[0] = '-';
}
else
{
$dns = file_get_html($url);
$ret = $dns->find('.price_g');
$nm = $dns->find('.price-item-title');
$csvdns = $csvdns.';'.$ret[0].';'.$nm[0];
echo $csvdns;
}
}
fclose($dnsdata);
?>
Появляется ошибка:
Warning: file_get_contents(http://shop[dot]mts[dot]ru/smartfony/sam[dot][dot][dot][dot][dot]00f-white[dot]html ): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/srv109190/pr/simple_html_d om.php on line 76
Fatal error: Call to a member function find() on a non-object in /home/srv109190/pr/index.php on line 18
Файл mts.txt вида:
http://shop[dot]mts[dot]ru/smartfony/sam[dot][dot][dot][dot][dot]00f-white[dot]html
http://shop[dot]mts[dot]ru/smartfony/sam[dot][dot][dot][dot][dot]00f-white[dot]html
http://shop[dot]mts[dot]ru/smartfony/sam[dot][dot][dot][dot][dot]00f-white[dot]html
http://shop[dot]mts[dot]ru/smartfony/sam[dot][dot][dot][dot][dot]00f-white[dot]html
Если же вставляю урл без цикла(не из файла, а напрямую):
$dns = file_get_html('http://shop.mts.ru/smartfony/samsung/smartfon-galaxy-j1-lte-duos-sm-j100f-white.html');
$ret = $dns->find('.price_g');
$nm = $dns->find('.price-item-title');
$csvdns = $csvdns.';'.$ret[0].';'.$nm[0];
echo $csvdns;
То все работает. Уже голову сломал, прошу помочь разобраться с проблемой! Заранее спасибо!
1. bongbong - 25 Ноября, 2015 - 16:00:12 - перейти к сообщению