How should parse with PHP (simple html dom parser) background images and other images of webpage?

For Case 1: // Create DOM from URL or file $html = file_get_html('google.com/'); // Get the style attribute for the item $style = $html->getElementById("id100")->getAttribute('style'); // $style = background:url(/mycar1. Jpg) // You would now need to put it into a css parser or do some regular expression magic to get the values you need. For Case 2/3: // Create DOM from URL or file $html = file_get_html('google.com/'); // Get the Style element $style = $html->find('head',0)->find('style'); // $style now contains an array of style elements within the head.

You will need to work out using attribute selectors what whether an element has a src attribute, if it does download the external css file and parse (using a css parser), if it doesn't then pass the innertext to the css parser.

To extract from the page you can try something like: $doc = new DOMDocument(); $doc->loadHTML("Foo"); $xml = simplexml_import_dom($doc); $images = $xml->xpath('//img'); foreach ($images as $img) echo $img'src' . ' ' . $img'alt' .' ' .

$img'title'; See doc for DOMDocument for more details.

– Gordon Jul 10 '10 at 19:37 I already write solution for img tag my answer only for background css image – Yosef Jul 10 '10 at 19:47.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions