KeithMar wrote:The method you used is very ingenious, and your script taught me a lot of imacros tricks in a very short time. I think I understand everything, whether I could write it myself is another matter! Would an alternative approach be to check the IMG name at R-1. If its Partions.png or Auction-hammer.png then we have a bad link, if its the bigger image in the first column we have a good link?
There are two other issues that I will need to solve. Your comments would be welcome as they would probably save me a lot of time. There is a banner across the page about halfway down. Below this the loans are marked 'bidding closed'. I don't want to follow any links below this point. I would have used !ENDOFPAGE but this is not available for Firefox so I'll need another plan.
Second is how to handle the LOOP. I need to run the macro in a loop so we keep looking for a link to click. When we find one, follow and extract data. But we need to stop the looping if there are no links to even consider, and reset back to 1 once we have clicked a link.
Thanks again for your help - I can't believe how dedicated you are! Hope you enjoyed the Music night as a break from a computer screen
Cheers, Keith
Oh...!, Thanks for the Compliments, "Ingenious" is maybe a big word, I rather use "Creative"...
I didn't want to use JavaScript in '.js' Scripts for Conditional Behaviour so I had/have to always be a bit "Creative" to achieve what I want in pure '.iim', you might find the following Thread interesting, I've explained a bit the Techniques that I use...:
-
Decision Making using iMacros/Possible Workarounds
About your "alternative approach to check the IMG name at R-1", I actually started in this Direction first (you can notice that I defined a 'Partition' Variable that I don't use, I only left it for Debugging in the PROMPT, and I first defined 'Good_Link' differently...), then I changed my mind for the Final Solution I used with 'URL_Left' and 'URL_Right' that I thought would be more reliable.
There is a Risk that if for any reason a Row doesn't have an Avatar Image, R-1 might catch the Partition Graphic from the Row above.
And if the URL and/or Name of the Partition Graphic had changed, the 'EVAL()' Statement to extract just the Name is always a bit complex with 'split()' / 'match()' / 'lastIndexOf()' / 'subStr()' / 'subString()' and you would have probably needed some Help again to modify the Script while with the Solution I gave you, you just need to record tagging the Elements again and you can modify the Script more easily...
>>>
I've added some Check about the Banner by simply using Relative Positioning on the Banner while checking at the same time if there is still at least one more Row with the desired Risk to check at the next Loop, and abort the Macro otherwise. + some mini-Reporting displayed at the end in the Side-Panel...:
Code: Select all
VERSION BUILD=8820413 RECORDER=FX
TAB T=1
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 0
'URL GOTO=file:///D:/TEMP/iMacros/Temp/Funding%20Circle/Funding%20Circle.html
'Risk Value we want to use: (Valid Values are: A / A+ / B / C)
SET Risk_Value "A+"
SET !LOOP 1
'Use a 'Risk_Value' Element as an Anchor for Relative Positioning:
'TAG POS=3 TYPE=TD ATTR=TXT:A+ // (Recorded)
TAG POS={{!LOOP}} TYPE=TD ATTR=TXT:{{Risk_Value}}
'>
'Extract the URL of the Link on the Left of the Risk Field:
SET !EXTRACT NULL
TAG POS=R-1 TYPE=A ATTR=TXT:* EXTRACT=HREF
SET URL_Left {{!EXTRACT}}
'>
'Check if there is any Partition Graphic on the Left of the Anchor:
'TAG POS=1 TYPE=IMG ATTR=SRC:https://d2ondqc76inyu3.cloudfront.net/images/partitions.png // (Recorded)
SET !EXTRACT NULL
TAG POS=R-1 TYPE=IMG ATTR=SRC:https://*.cloudfront.net/images/partitions.png EXTRACT=TXT
'>
'If there is no Partition Graphic at R-1, we know that the Link is Good:
SET Partition EVAL("var s='{{!EXTRACT}}'; var x; if(s=='#EANF#'){x='NO';} else {x='YES';}; x;")
'>
'Extract the URL of the Link (if any) on the Right of the Partition Graphic:
SET !EXTRACT NULL
TAG POS=R1 TYPE=A ATTR=TXT:* EXTRACT=HREF
SET URL_Right {{!EXTRACT}}
'>
'SET Good_Link EVAL("var p='{{Partition}}'; var x; if(p=='NO'){x=1;} else {x=999;}; x;")
SET Good_Link EVAL("var ul='{{URL_Left}}'; var ur='{{URL_Right}}'; var x; if(ul!=ur){x=1;} else {x=999;}; x;")
'>
TAG POS={{!LOOP}} TYPE=TD ATTR=TXT:{{Risk_Value}}
'TAG POS=1 TYPE=A ATTR=TXT:Property<SP>Development<SP>In<SP>Liss<SP>3 // (Recorded)
TAG POS=R-{{Good_Link}} TYPE=A ATTR=TXT:*
'Checking we are still above the Middle Banner and there is at least one more Row with the desired Risk to check,
'abort the Macro otherwise...
'Banner:
'TAG POS=1 TYPE=IMG ATTR=SRC:https://d2ondqc76inyu3.cloudfront.net/images/loan-parts-banner.png // (Recorded)
'>
TAG POS={{!LOOP}} TYPE=TD ATTR=TXT:{{Risk_Value}}
TAG POS=R1 TYPE=TD ATTR=TXT:{{Risk_Value}}
SET !EXTRACT NULL
TAG POS=R1 TYPE=IMG ATTR=SRC:https://*.cloudfront.net/images/loan-parts-banner.png EXTRACT=TXT
PROMPT URL_Left:<SP>{{URL_Left}}<BR>URL_Right:<SP>{{URL_Right}}<BR>Partition<SP>Graphic?:<SP>{{Partition}}<BR>Good_Link:<SP>{{Good_Link}}
SET Summary <SP><SP>No<SP>Error...!<BR><BR>
ADD Summary "Last Row with Risk = "
ADD Summary {{Risk_Value}}.<BR>({{!LOOP}}<SP>Row(s)<SP>processed...)<BR><BR><BR><BR>
SET !ERRORIGNORE NO
SET Abort_Macro EVAL("var s='{{!EXTRACT}}'; if(s=='#EANF#'){MacroError('{{Summary}}');}")
SET !ERRORIGNORE YES
'PAUSE
(Written and Tested on iMacros for FF v8.8.2, Pale Moon v24.6.2 (=FF31), Win7-x64.)
>>>
And yep, I enjoyed the Music, I'm a DJ so it's rather for other People to like my Music, ah-ah...!
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...