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

前端 未结 2 611
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-18 15:46

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

case 1: inline css



        
2条回答
  •  不思量自难忘°
    2020-12-18 16:23

    To extract from the page you can try something like:

    $doc = new DOMDocument(); 
    $doc->loadHTML("Foo
    \"alt\""); $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.

提交回复
热议问题