iMacros EVAL没有给出正确的输出



好的,所以我试图从网站上抓取一些信息,试图解释像11/22[50%]这样的值。我可以保证该值至少是子字符串大小所需的最小值。到目前为止,代码可以找到数据,提取数据并将其设置为!VAR1。然而,由于某种原因,我不能让它把!VAR2在页面上的输入字段。它会正确切换,找到输入字段并输入"Extraction Results:",就是这样。

所以我的输入是11/22[50%],我只想要11。我从位置1,2开始拆分字符串得到11

根据iMacros wiki我的语法是正确的,宏运行,我只是没有得到预期的输出,我认为是因为我的EVAL行。有人知道为什么吗?如果您能解释一下,我将不胜感激。

VERSION BUILD=7601105 RECORDER=FX
TAB T=1
'Go to website
URL GOTO=http://xxxxxxxxxxxxxxxxxxxx
'Set tag to refer to next
TAG POS=1 TYPE=TD ATTR=TXT:Nerve:
'Get the relative position of something that cannot be tagged and extract the cell's info
TAG POS=R1 TYPE=TD ATTR=TXT:* EXTRACT=TXT
'Set VAR1 to Extracted info (For debugging)
SET !VAR1 {{!EXTRACT}}
'Issue must be here, this is trying to run javascript substring on the information harvested.
SET !VAR2 EVAL("var s="{{!EXTRACT}}"; s=s.substring(1,2); s;")
"Extract to null value to be referenced later
SET !EXTRACT NULL
'Test VAR2 by going to another page and posting the info in a textbox.
URL GOTO=http://xxxxxxxxxxxxxxxxxxxx
TAG POS=1 TYPE=INPUT ATTR=NAME:search[id] CONTENT=Extraction<SP>results:{{!VAR2}}

尝试使用

SET !VAR2 EVAL("var s="{{!EXTRACT}}"; s=s.split("/")[0];s;")

string .split()函数将字符串分割成一个数组,当它找到你作为参数的任何部分时,每个部分被分开,该参数可以是RegExp或string。

数组中的第一个对象([0])将是找到第一个"/"之前的文本。

Then I return s,那么eval();将返回正确的输出