Wednesday 16 April 2014

Get all images tags from the remote url through php

In some project i need to get all image tags from the remote url
I have google a lot but not getting any particular solution.
But atlast i got a very good code which works like a charm

you can find that code on

https://docs.google.com/file/d/0B9cbYvYQ9b0YY2xxUW5kUms0NWM/edit

in this file you will see the below code at very last of file


// Create DOM from URL or file
$html = file_get_html('https://www.google.co.in/'); // replace your url

// Find all images
foreach($html->find('img') as $element) // to get all image src  from the url
       echo $element->src . '<br>';

// Find all links
foreach($html->find('a') as $element) // to get all anchor tags  from the url
       echo $element->href . '<br>';


with this script you can get any paramaeter from the remote url.  Remember to copy the full file from the downlaod file from here






      

No comments:

Post a Comment