split a string to get the value?

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

split a string to get the value?

by a2515125 on Mon Mar 13, 2017 10:24 pm

hey

I would liike to get the certain numbers from string but struggle how to get them

I need to get the numbers 33 for later use

but my code only can get first 3 or second 3 or 33 評價 , do not know how to get only 33 :!:


I already try my best but still failed to get pure 33

Image

Code: Select all


TAG POS=1 TYPE=P ATTR=CLASS:small EXTRACT=HTM
SET !VAR1 EVAL ("var s='{{!EXTRACT}}'; var x,y,z; z=s.split('e;\">');y= z[1].split('</p');y[0];")
PROMPT {{!EXTRACT}}
PROMPT {{!VAR1}}






windows10/ffv51/imacros v8.9.7
Last edited by a2515125 on Tue Mar 14, 2017 10:13 am, edited 2 times in total.
a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: split a string to get the value?

by iimfun on Tue Mar 14, 2017 12:58 am

Hey,

Here is a pure code for "pure 33"
Code: Select all
TAG POS=1 TYPE=P ATTR=CLASS:small EXTRACT=TXT
SET !VAR1 EVAl("parseInt('{{!EXTRACT}}')")
iimfun
 
Posts: 239
Joined: Tue Jul 19, 2016 6:06 am

Re: split a string to get the value?

by a2515125 on Tue Mar 14, 2017 3:30 am

thank you iimfun, it did work to get pure 33


however, when I put the !VAR1 ( extract !VAR1 get pure value =33 ), and run js as counter. the imacros says

ReferenceError: VAR1 is not defined, line 9 (Error code: -1001)

I thought !VAR1 can be reused as 33 , isnt it?

I have two iim and one js as counter, the !VAR1 value will decide how many time to extract

it seems that my js has pb but i cannot detect or do not know how to call !VAR1 in js



2.iim

Code: Select all
SET !EXTRACT_TEST_POPUP NO
SET !REPLAYSPEED FAST
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0

'count how many evaluation'
TAG POS=1 TYPE=P ATTR=CLASS:small EXTRACT=TXT
SET !VAR1 EVAL("parseInt('{{!EXTRACT}}')")

'trigger more evaluation button'

TAG POS={{!VAR1}} TYPE=BUTTON ATTR=CLASS:btn<SP>btn-link<SP>u-decorate-none<SP>u-bottom-mar&&DATA-REACTID:*



'grab each evaluation urls'

TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:media-left<SP>u-pad<SP>u-decorate-none EXTRACT=HREF


SAVEAS TYPE=EXTRACT FOLDER=C:\Users\a2515125\Desktop\iMacroscript FILE=carousell_seller3.csv



1.iim
Code: Select all

SET !REPLAYSPEED FAST
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 0
SET !DATASOURCE C:\Users\a2515125\Desktop\iMacroscript\carousell_seller.csv
SET !LOOP 1

URL GOTO={{!LOOP}}


js as counter
Code: Select all



var j;
      for (j =1; j <999999; j++){
          iimSet("j", j);
          iimPlay("2.iim")

var i;
       for (i =0 ; i = !VAR1; i++){
          iimSet("i", i);
          iimPlay("1.iim")
      }
}

a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: split a string to get the value?

by iimfun on Thu Mar 23, 2017 1:19 am

I think you should learn of how the iimGetExtract function works.
iimfun
 
Posts: 239
Joined: Tue Jul 19, 2016 6:06 am


Return to General Support & Discussions

Who is online

Users browsing this forum: No registered users and 10 guests

-->