v2.5.2
Giriş yap

simple_html_dom innertext sorunu

emmir2
360 defa görüntülendi

<?php

include 'class.php';

$html = file_get_html('http://eshop.erhanteknik.com.tr/urunlerimiz?categoryId=1');
?>

<?php 
foreach ($html->find('.product-image a') as $element){ ?>

<img src="<?php echo $element->find('img',0)->src; ?>" alt="">
<div><?php echo $element->find('.product-codenumber', 0)->innertext; ?></div>
<?php } ?>

aldığım hata
<b>Notice: Trying to get property 'innertext' of non-object in C:\xampp\htdocs\curl\index.php on line 12</b>

abdullahx
688 gün önce

Hiyerarşi ile ilgili ufak sorunların vardı

<?php
$html = file_get_html('http://eshop.erhanteknik.com.tr/urunlerimiz?categoryId=1');
$find = $html->find('.product-image > a');

if (count($find)) {
    foreach ($find as $item){ ?>
        <img src="<?= $item->find('img',0)->src; ?>" alt="">
        <div><?= $item->next_sibling()->next_sibling()->plaintext ?></div>
    <?php }
}