質問

I would like to ask how do I extract the First and Last names separately from random name generated from this URL: http://www.fakenamegenerator.com/gen-male-nl-ca.php

TAG POS=1 TYPE=H3 ATTR=TXT:*<SP> EXTRACT=TXT
SET !EXTRACT_TEST_POPUP NO
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL

TAG POS=1 TYPE=H3 ATTR=TXT:<SP>* EXTRACT=TXT
SET !EXTRACT_TEST_POPUP NO
SET !VAR2 {{!EXTRACT}}
SET !EXTRACT NULL

At the moment, my iMacros script extracts the whole name for both variables. I would like to assign the First Name to VAR1 and Last Name to VAR2.

I'm afraid I do not know JavaScript, so I would appreciate explicit help.

役に立ちましたか?

解決

You'll have to use Javascript and some regexp here because both first name and last name are placed in the same tag.

SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=H3 ATTR=TXT:*<SP> EXTRACT=TXT
SET VAR1 eval("\"{{!EXTRACT}}\".match(/^\\s*\\S+/)[0]")
SET VAR2 eval("\"{{!EXTRACT}}\".match(/^\\s*\\S+\\s+(.+)\\s*$/)[1]")
PROMPT "VAR1={{VAR1}}, VAR2={{VAR2}}"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top