开发者

Simple HTML DOM css

开发者 https://www.devze.com 2023-01-30 13:34 出处:网络
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.

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?


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)
0

精彩评论

暂无评论...
验证码 换一张
取 消