G
G
generate2020-06-17 10:15:55
Parsing
generate, 2020-06-17 10:15:55

PHP simple HTML DOM how to get attributes?

<?php
include_once('simple_html_dom.php');

$html = file_get_html(' https://site.com ');

$element = $html->find( "img" );
echo count($element);
echo $element[4];

?>

$element[4] contains many images and one image that I need with the data-src attribute. How to display it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
generate, 2020-06-17
@generate

I found a way first through HTML Dom and then with phpQuery you can.
$img = $element[4];
$img1 = pq('img') ->attr("data-src");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question