if I have a url (var $url) how do I preg_match the images in that url?
I want to display all of the images within the $url document
-----
to make things a little more complex (I dont know if this can be done) I want content related images -- not header graphics, not "contact me" graphics or any icons... just the images that are within the body of the text -- - I really don't think this can be done because the $url can be any website...
if I have a url (var $url) how do I preg_match the images in that url?
I want to display all of the images within the $url document
-----
to make things a little more complex (I dont know if this can be done) I want content related images -- not header graphics, not "contact me" graphics or any icons... just the images that are within the body of the text -- - I really don't think this can be done because the $url can be any website...
It's not clear for me. Do you want to take a url, let's say http://www.google.com/ and extract from that page all attributes src of html tags img?
this can be done, about filtering, without icons, contact, I don't thing there is a programmatic solution, maybe manual. A page, with all new pictures retrived from last process and manual checking.
problem is that it only gets the first image for every page -- sometimes it doesn't show any images.... how do I get it to get all of the images on a page?
problem is that it only gets the first image for every page -- sometimes it doesn't show any images.... how do I get it to get all of the images on a page?
- try with preg_match_all
- check the results, if the path is relative for example img/pic.jpg you must add the url to transform in http://www.google.com/img/pic.jpg
- it could be something like /img/pic.jpg, you must remove the / to avoid duplicate as //
- if is absolute is allready ok
- all the path must be absolute in the end
foreach($images as $img){ print '<img src="'.$img.'">'; }
?>
I abuse a litle of regex, is far to be best solution, the idea was to fit as much possible situatiion I can imagine. It can extract if the site hide image using javascript.
I don't test it with url with ? inside, and you must keep in mind to use urlencode in some situation.
you can easy use strxxx instead of regex in few lines,