imacros, create folder structure as EXTRACT as HREF root

347 Views Asked by At
TAG POS=4 TYPE=IMG ATTR=STYLE:margin:*15px*&&SCR:*&&ALT:* EXTRACT=HREF
ONDOWNLOAD FOLDER=D:\\temp\\img\\ FILE=* WAIT=YES
TAG POS=4 TYPE=IMG ATTR=SRC:/upload/images/* CONTENT=EVENT:SAVEPICTUREAS

with above code, the EXTRACT HREF get :

"http://ext-domain.com/images/products/78/403/11132/1/279/seagate-ext-drive-(1).jpg"

actually there is more than one image on the page, with different names and exts

"http://ext-domain.com/images/products/78/403/11132/1/279/seagate-ext-drive-(1).jpg"
".. same as above....................................... /seagate-ext-drive-(2).gif"
".. same as above....................................... /i/seagate-ext-drive-small-(1).gif"
".. same as above....................................... /i/seagate-ext-drive-small-(2).jpg"

(sorry .. same as above.. is ..http.../78/403/11132/1/279/.. ,because still need 10 reputations to post )

and all my images save to :

D:\temp\img\

How to make imacros save this image to

D:\temp\img\78\403\11132\1\279\seagate-ext-drive-(1).jpg
D:\temp\img\78\403\11132\1\279\seagate-ext-drive-(2).gif
D:\temp\img\78\403\11132\1\279\i\seagate-ext-drive-small-(1).gif
D:\temp\img\78\403\11132\1\279\i\seagate-ext-drive-small-(2).jpg

I repeat the code from TAG 1 to TAG 4 to get 4 images

1

There are 1 best solutions below

4
On BEST ANSWER

Try this code:

SET myFolder D:\temp\img\
TAG POS=4 TYPE=IMG ATTR=SRC:/upload/images/* EXTRACT=HREF
SET !EXTRACT EVAL("'{{!EXTRACT}}'.match(/\/upload\/images\/(.*)image\.jpg/)[1];")
SET !EXTRACT EVAL("'{{!EXTRACT}}'.replace(/\\//g, '\\\\');")
ADD myFolder {{!EXTRACT}}
ONDOWNLOAD FOLDER={{myFolder}} FILE=image.jpg WAIT=YES
TAG POS=4 TYPE=IMG ATTR=SRC:/upload/images/* CONTENT=EVENT:SAVEPICTUREAS