@artemka170691

Как исправить, ssl блокирует парсер simple_html_dom?

Подскажите как применить код №1, к моему №2, перепробовал все варианты уже. Парсер блокируется ssl.
Код №1:
$arrContextOptions=array(
    "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);
$html = file_get_html("https://new.starbyte.ru/article/{PRODUCT_ID}", false, stream_context_create($arrContextOptions));


Код №2:
<?php
namespace Supplier;
use Model\Supplier;
defined('PIMPORT') or die('Error access');
/**
 * Class NEWW
 * @package Supplier
 */
class NEWW extends \Infr\Supplier {
    /** @var string */
    protected $_host = 'https://new.starbyte.ru';
    /** @var string */
    protected $_productMask = 'https://new.starbyte.ru/article/{PRODUCT_ID}';
    protected function _getPrice() {
        //проверяем подключен ли плагин и к нему поставщик
        $class = 'Plugins\Suppliers\Supplier\NEWW';
        if (class_exists($class)) {
            /** @var \Plugins\Suppliers\Infr\Supplier $supplierItem */
            $supplierItem = new $class;
            $pricePath = $supplierItem->getPricePath();
            if (file_exists($pricePath)) {
                return file_get_contents($pricePath);
            } else {
                throw new \Exception('Прайс-лист для поставщика не загружен');
            }
        } else {
            throw new \Exception('К плагину Suppliers не подключен нужный поставщик');
        }
    }
    public function getProduct(Supplier $supplier, Supplier\Product $product, array $params = array()) {
        if ($product->url) {
            $html = \Infr\Request::httpRequest($product->url);			
			if ($html) {
				$dom = \Infr\str_get_html($html);
				if ($dom) {
					$pics = $dom->find('.photos a');
if ($pics) {
foreach($pics as $pic) {
$product->pictures[] = 'http:'.$pic->getAttribute('href');
}
}
                    $techpars = $dom->find('.tab-content', 0);                        
						 if ($techpars){
$techpars = preg_replace("!<a class=\"link\"(.*?)>(.*?)</a>!si","\\2",$techpars); //Удаление ссылок
$techpars = preg_replace("!<a(.*?)>(.*?)</a>(.*?)</nobr>!si","\\2",$techpars); //Удаление ссылки PDF
                         $desc = $techpars;
                         $product->description = $desc;
						 
                         }        
					unset($dom);
				}
			}
            unset($html);
        }

        return $product;
    }
  • Вопрос задан
  • 146 просмотров
Пригласить эксперта
Ответы на вопрос 1
@rPman
загрузи страничку вручную тем же curl а парсеру корми строчку методом str_get_html
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы