Friday, 16 August 2013

How to get images for a URL through php?

We can use many concepts for this eithe we can use DOM or CURL or anything. Lets see a simple example on how to use DOM concept





$doc = new DOMDocument();
$doc->loadHTML('Your URL');
$imageTags = $doc->getElementsByTagName('img');

foreach($imageTags as $tag) {
$img_src= $tag->getAttribute('src');
}





By this we can get all the image tag in the particular URL, you can write separate scripts for Image types too.

No comments:

Post a comment