I'm trying to save a bunch of photos but instead of using the URL file name, my goal is to rename it with the photo ID found in the URL also. The plan is:
1. The macro runs on a page like this:
https://www.motorsport.com/all/photo/ma ... /?a=906516
2. Then it finds the main image URL, which is:
https://cdn-1.motorsport.com/images/mgl ... -honda.jpg
3. Replace the "s8" text to "s7", in order to change the image resolution. And opens the new URL.
4. Use regex to get the image ID from the URL. Which is the "2epn5ab0" between "mgl" and "s7".
-------------------------
I'm managing to get to step 3 without problems with this code:
Code: Select all
TAG POS=1 TYPE=IMG ATTR=SRC:*images/mgl* EXTRACT=HREF
SET newURL EVAL("\"{{!EXTRACT}}\".replace(\"s8\", \"s7\");")
URL GOTO={{newURL}}
I tried to follow the same EVAL syntax as above to match the image ID like this:
Code: Select all
SET partialID EVAL("\"{{newURL}}\".match(\"(?=mgl\/)(.*)(?=\/s7)\");")
PROMPT {{partialID}}
-------------------------
Then I found a few possible solutions on Stackoverflow and tried like this suggestion.
Code: Select all
SET partialID EVAL("var s=\"{{newURL}}\"; s.match(\"(?=mgl\/)(.*)(?=\/s7)\"); s[0];")
MacroSyntaxError: wrong format of SET command, line 9 (Error code: -910)
Any ideas of what I might be missing?
P.S.: iMacros for Firefox 9.0.3