How to put image url using SimpleHtmlDom?

Hello.
there is here such code
<div class="img" style="background:url(...)"> </div>

I tried to do:
$element = $html->find('div.img');
 $style = $element->getAttribute('style');

But nothing poluchaetsya.
July 8th 19 at 15:25
3 answers
July 8th 19 at 15:27
Try using a regular expression
shd is fine everything himself regularit, why not to use them, the guy just a bit nedorazumeniya in it. When meeting with this class, I met exactly the same misunderstanding. Yes, and the documentation author is somehow sluggish explained. - sally_Carro commented on July 8th 19 at 15:30
July 8th 19 at 15:29
By default, find searches a number of sites and returns the data in an array
<?php
require_once 'libs\simple_html_dom.php';
$htmldata = '<div class="img" style="background:url(...)"--> ';
$data = new simple_html_dom();
$data->load($htmldata);
foreach($data->find('div.img') as $value){
 echo $value->getAttribute('style');
}

If you have 100% confidence that you need to take only 1 item, the solution to the following:
$element = $data->find('div.img',0);
echo $element->getAttribute('style');

Well, or:
$element = $data->find('div.img');
echo $element[0]->getAttribute('style');
I did that. I guess the thing is how do I get the page. I'm taking it with Kurla. And then work with str_get_html(). Maybe in this case? - sally_Carro commented on July 8th 19 at 15:32
: well take her through curl, no problem, then as in my example create a new object and use load, I use curl to send data with the necessary parameters (for example post) then the answer throws in the parser SHD and forth. Why not then? - vinnie_Skiles commented on July 8th 19 at 15:35
: The problem is that when I take the page Cullom and deduce it from itself, everything is fine, when you load the page in a new dom, the page is cleared, and the pictures disappear. Here out of here I'm trying to take a picture aukro.ua/aukcion-2-noutbuka-fujitsu-c-1grn-pod-vos... - sally_Carro commented on July 8th 19 at 15:38
: as far as I know shd can normalize the html filters that you need? If so, you should look at other implementations of parsing. - vinnie_Skiles commented on July 8th 19 at 15:41
No, my example works. Gruzani through the load check. - sally_Carro commented on July 8th 19 at 15:44
: Load the same, apparently pictures pogruzhayutsya using Java or something. Kurlu normal, and dom spravlyaetsya - sally_Carro commented on July 8th 19 at 15:47
If you think that the JavaScript loads after, then you using watir, he spit on everything and everyone. - vinnie_Skiles commented on July 8th 19 at 15:50
Still have goose parser, but I haven't seen any of his work. - sally_Carro commented on July 8th 19 at 15:53
July 8th 19 at 15:31
In the documentation of the PHP Simple HTML DOM Parser are parsing the images :

simplehtmldom.sourceforge.net

Find more questions by tags PHP