Reputation: 2344
I am trying to get images from a URL using php. I used this link Get all images url from string
I got it working, but As I tested it, I came across URLs, where
URL is www.myurl.com/pianos/new/steinway.html?kID=243
which can contain an image
either <img src="/images/SteinwayGrand.jpg">
or <img src="http://www.myurl.com/images/SteinwayGrand.jpg">
I am trying to address both these cases, and make the script working, ie display images on my page. Can anyone suggest some way to cover this kind of tags?
Upvotes: 0
Views: 99
Reputation: 2344
Got the answer from this post:
Scrape FULL image src with PHP
with bit of modification to match my application.
Upvotes: 1
Reputation: 487
using php you could use str_replace to cahnge the ../ to / as in:
$new_url = str_replace("../", "/", $url);
where str_replace(needle, haystack, input_String);
If not, you caould find a way to do the same in js.
ADDED INFO You could use it as in:
$new_url = str_replace("../", "http://www.website.com/", $url);
this will replace any ../ into http://www.website.com/
Upvotes: 0