Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getParamsXCom($articul)
- {
- // подключаем страницу html товара
- $_products = phpQuery::newDocument(file_get_contents('https://www.xcom-shop.ru/search/?o=n&s='.$articul));
- $link = 'https://www.xcom-shop.ru' . $_products->find('div.wrap div.name a')->attr('href');
- $detail_page = phpQuery::newDocument(file_get_contents($link));
- $arr = [];
- foreach ($detail_page->find('#prop-columns .prop-line.delimiter') as $char) {
- $category = pq($char);
- $props = [];
- $i = 0;
- // подобие функции .nextUntil в JQuery
- foreach($category as $child) {
- if($i == 2){ break; }
- $i = (pq($child)->attr('class') == 'delimiter') ? ($i + 1) : $i;
- if($i == 0){ continue; }
- foreach(pq($child) as $el) {
- $props[$el->find('.call').text()] = $el->find('.prop-value')->text();
- }
- }
- $arr[$category->text()] = $props;
- }
- print_r($arr);
- }
- print_r(getParamsXCom('4YV96ES'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement