Thankyou for that.. I have used LWP::Simple to grab a web page.. and save it to a local file.. and I have also retrieved all the images (if any) that were on that page as well..
so then I edit all the image links to point to the local copies I downloaded.. (This script was designed to get around an issue with SSL, so I can display the result page of a script still within SSL by getting the page remotely and displaying it locally on the SSL machine while still protected by the certificate.. So I need to get all image urls, both relative and absolute to point to the local copies of the image... This variable designates the local image path : $images_url thanks again and any further tips would be wonderful.. regards Franki -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Moshe Kaminsky Sent: Sunday, August 11, 2002 4:44 PM To: frankie Cc: [EMAIL PROTECTED] Subject: Re: [newbie] perl question. Hi, I think you want to use URI->new_abs instead of URI->abs. But it depends on whether all addresses have the same common base that you want to change. HTH Moshe * frankie <[EMAIL PROTECTED]> [020807 21:54]: > thanks,,,, > > I got that bit sussed, but I'm stuck on something else now,,, > > How good are you at regex??? > > I have this: > > $line =~ s/ > # First look for an a, img, or area, followed later by an href > or src > (<\s*(?:a|img|area)\b[^>]*(?:href|src)\s*=\s* > # Then an optional quote > ['"]?) > ([^'"> ]+) > # Then another optional quote > (['"]? > [^>]*>) > / > # Then construct the new link from the prefix and suffix > $1.sprintf("%s",URI->new($2)->abs($images_url)).$3 > /segix; > > It replaces all relative url's with my new path.. (maintaining the image > name though.) > > I need it to replace ALL image paths.. not just relative paths.. > > got any ideas what changes I need to make so it replaces both absolute and > relative urls?? > > regards > > > Frank > > -----Original Message----- > From: David Stevenson [mailto:[EMAIL PROTECTED]] > Sent: Thursday, August 08, 2002 2:13 AM > To: [EMAIL PROTECTED] > Subject: RE: [newbie] perl question. > > > open(COM,"<filename") or die; > while (<COM>) > { > @array = split /\//,$_; > $file = $array[$#array]; > } > > # you might want to chomp() it to remove /n > > HTH > Dave > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of frankie > Sent: 07 August 2002 14:56 > To: [EMAIL PROTECTED] > Subject: [newbie] perl question. > > > Hi guys, > > do we have any perl gurus here??? > > I have an array of image url's... > > they look something like this: > > http://mydomain.com/images/image.gif > http://another.domain.com/image.jpg > http://somewhere.com/image.png > > > I need to loop through that with a foreach loop and for each one, split the > filename off from the url. > > so in the first example, I want to get this: > > image name: image.gif > image path: http://mydomain.com/images/ > > something like this: > > ############################ > foreach $image (@my_images){ > > ($url, $image_name) = split... #or whatever can best split them > > get_image($url, $imagename, $local_dir); #fetch image and save locally. > > } ## end of foreach. > ############################ > > > any ideas anyone?? does any of the URI:: or file:: modules work for urls? > is there a simple regex thats case insensitive and will work on all image > file types? (ie jpg, gif, png, tif, bmp etc..) > > > Any tips would be fantastic... > > > rgds > > Frank > > > > > > > Want to buy your Pack or Services from MandrakeSoft? > Go to http://www.mandrakestore.com
Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
