Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple HTML DOM css

Tags:

css

php

I am using Simple HTML DOM to get content from a website. However some of the images do not display because they are set as backdroung images from an external so I have called this in also.

However the image dose not have the full path.

<style>    
div.spriteImgSmall { background: url(/images/css_sprites/film_sprites/smallimages_sprite.jpg); } 
    div.spriteImgSmall_17826 { background-position: -0px -0px; width: 86px; height: 64px; }
</style>

There are no head or body tags as this is part of a facebook app. How could I use Simple HTML DOM to add on the base url to the path?

like image 688
Keith Avatar asked Feb 16 '26 09:02

Keith


1 Answers

DOM deals with structured HTML, however what you've got there is CSS, which for DOM is just unstructured text. So probably your best approach would be:

  1. Parse HTML DOM, find style tags
  2. Take contents of the style tag by using something like (string)$dom->style
  3. Parse the content with preg_match(), looking for url(blah-blah)
like image 132
StasM Avatar answered Feb 18 '26 23:02

StasM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!