regstuff wrote:Code: Select all
VERSION BUILD=1002
Chrome: Version 61.0.3163.100 (Official Build) (64-bit)
Windows 10
Hi,
I've created a macro to scrape an element from a certain page, and then store that data in a variable, and use that variable to determine what link to click on another page.
Like so:
Code: Select all
'Extract the data and store it
TAG POS=1 TYPE=DIV ATTR=CLASS:del EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
'Use the stored data to choose another link
TAG POS=1 TYPE=A ATTR=TXT:{{!VAR2}}
The variable is picking up the data fine, and if instead of using the variable, I insert the actual data itself, the code runs fine. The uses wildcards, and so !VAR2 is in the format *WEBSITENAME*
But I get this error: RuntimeError: element A specified by TXT:{{!VAR2}} was not found, line: 12
Which is strange because the element is actually there on the page, and as I said, if I change the code to use the data itself, instead of a variable, it works fine.
No need to open Duplicates, I guess you'll have understood...
And I'm not sure your Thread will be specific to the 'iMacros for CR' Sub-Forum..., unless your Script works fine in some other Browser but only fails on CR..., which you then should have mentioned...
But OK, good Quality anyway... (Some Word is missing in "The [Site?] uses wildcards,"...)
OK, if I understand correctly, you literally get "TXT:{{!VAR2}}" in the RuntimeError, and '{{!VAR2}}' doesn't get converted to the Value/Content it should use..., possibly related to the 2 outer Wildcards around the Site Name... You didn't post the URL, then I cannot have a look myself...
- You don't really need to use an extra Temp Var ('!VAR2'), you could use "ATTR=TXT:{{!EXTRACT}}" directly, as you only do one Extract and you don't do any Manipulation on the Content of the Extract... (even if that shouldn't play a role...)
- You should make sure that the '!EXTRACT' is "clean" and doesn't contain any Spaces and/or Soft Returns (that you would then need to 'trim()' using 'EVAL()'). You can check that with a simple 'PROMPT':
Code: Select all
PROMPT EXTRACT:<SP>_{{!EXTRACT}}_<BR>VAR2:<SP>_{{!VAR2}}_
The Underscores around the 2 Vars are meant to display any Spaces/Soft Returns.
- I actually used recently a Wildcard inside a Var to reuse that Var for a 'TAG' 'ATTR' like you do, and I wasn't sure it would work correctly..., but it does..., but "my" Wildcard is in the middle or the Var and not at the beginning + end like in your case. (And I use a different Browser and therefore a different iMacros "Flavour"...)
- If the Pb is those 2 Wildcards, you might need to remove them from the '!EXTRACT' using 'EVAL()'..., and you'll need to add them again in the 'TAG' Statement, but outside the '{{!VAR2}}' and they then will be treated like "real" Wildcards by iMacros...
This should do the Trick, I would think...:
Code: Select all
'Extract the data and store it
TAG POS=1 TYPE=DIV ATTR=CLASS:del EXTRACT=TXT
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var z=s.split('*'); z[1];")
PROMPT EXTRACT:<SP>_{{!EXTRACT}}_<BR>VAR2:<SP>_{{!VAR2}}_
'Use the stored data to choose another link
TAG POS=1 TYPE=A ATTR=TXT:*{{!VAR2}}*
(Not tested...)
- (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...