Seeking to append a number to a single URL and loop activity

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
abrooks
Posts: 2
Joined: Thu Jun 20, 2019 11:51 pm

Seeking to append a number to a single URL and loop activity

Post by abrooks » Sun Jun 23, 2019 3:53 pm

Specs:
Win 10
iMacros 12.5 Enterprise
Firefox (or could be chrome, same script)

Hi. Purchased in March, getting started. Long story short I have a .csv file with 1 column, all numbers. Want to loop through them to perform a few brief function, clicking a few buttons, waiting for an action to complete. When done go back to .csv and start with the next number in COL1, but the number has to be appended to the end of a static URL which never changes. It'sd always the same format: www.example.com/123456

Script so far:

TAB T=1
SET !DATASOURCE C:\Users\username\Desktop\macro.csv
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES
URL GOTO=https://www.whatever.com/123456
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:guick-load ATTR=ID:quick-load-button
TAG POS=1 TYPE=A ATTR=TXT:Subscriptions
TAB T=2
WAIT SECONDS=12
TAG POS=1 TYPE=A ATTR=TXT:Manage
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:subscriptionControlForm ATTR=ID:cancel_service_confirmation-cancel_service_confirmation-subscriptionControlForm CONTENT=YES
TAG POS=1 TYPE=A ATTR=TXT:Yes,<SP>I’m<SP>sure
WAIT SECONDS=25
TAB CLOSE
TAB T=1

What I would like to do is cycle through the URL GOTO line by appending what I have which are account numbers in COL1 of the datasource .csv file. They are not in order or have no real format other than being numbers.

I have it in my head that I could use something like this, but it doesn't work:
URL GOTO=https://www.whatever.com/{{!COL1}}

Each csv file would have maybe 100 numbers one day, maybe 20 the next, doesn't matter.

i did manage to manually create URLs to go to in excel and place those in column 1. Can I modify the URL GOTO command to read the url from COL1 as a workaround? Banging my head here.

Thank in advance. My first post. YAY.
chivracq
Posts: 8625
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Seeking to append a number to a single URL and loop activity

Post by chivracq » Sun Jun 23, 2019 4:32 pm

abrooks wrote:
Sun Jun 23, 2019 3:53 pm
Specs:

Code: Select all

Win 10
iMacros 12.5 Enterprise
Firefox (or could be chrome, same script)
Hi. Purchased in March, getting started. Long story short I have a .csv file with 1 column, all numbers. Want to loop through them to perform a few brief function, clicking a few buttons, waiting for an action to complete. When done go back to .csv and start with the next number in COL1, but the number has to be appended to the end of a static URL which never changes. It'sd always the same format: www.example.com/123456

Script so far:

Code: Select all

TAB T=1
SET !DATASOURCE C:\Users\username\Desktop\macro.csv
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES
URL GOTO=https://www.whatever.com/123456
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:guick-load ATTR=ID:quick-load-button
TAG POS=1 TYPE=A ATTR=TXT:Subscriptions
TAB T=2
WAIT SECONDS=12
TAG POS=1 TYPE=A ATTR=TXT:Manage
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:subscriptionControlForm ATTR=ID:cancel_service_confirmation-cancel_service_confirmation-subscriptionControlForm CONTENT=YES
TAG POS=1 TYPE=A ATTR=TXT:Yes,<SP>I’m<SP>sure
WAIT SECONDS=25
TAB CLOSE
TAB T=1
What I would like to do is cycle through the URL GOTO line by appending what I have which are account numbers in COL1 of the datasource .csv file. They are not in order or have no real format other than being numbers.

I have it in my head that I could use something like this, but it doesn't work:

Code: Select all

URL GOTO=https://www.whatever.com/{{!COL1}}
Each csv file would have maybe 100 numbers one day, maybe 20 the next, doesn't matter.

i did manage to manually create URLs to go to in excel and place those in column 1. Can I modify the URL GOTO command to read the url from COL1 as a workaround? Banging my head here.

Thank in advance. My first post. YAY.
Thread not really specific to iMacros for FF, correct Sub-Forum to open your Thread would have been the 'General' Sub-Forum...

Your Thinking/Approach is correct, this is/should be the correct:

Code: Select all

URL GOTO=https://www.whatever.com/{{!COL1}}
Not mentioned in your FCI, but in FF (v67...?), you had to also install the iMacros for FF Add-on, => v10.0.2, I reckon...?
And in order for v10.0.2 for FF to be able to access your DataSource and to retrieve the '{{!COL1}}', you also need to install the 'FIO'-Module for Local File-Access... (... which you can download from your Ipswitch/Progress Portal...).

Try this little Script:

Code: Select all

TAB T=1
SET !DATASOURCE C:\Users\username\Desktop\macro.csv
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
'SET !ERRORIGNORE YES

SET URL_Site https://www.whatever.com/
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>COL1:<SP>_{{!COL1}}_<BR>URL_Site:<SP>_{{URL_Site}}_<BR>URL:<SP>_{{URL_Site}}{{!COL1}}_
WAIT SECONDS=2
URL GOTO={{URL_Site}}{{!COL1}}
WAIT SECONDS=2
... And loop a few times this Script and inspect/check the Content of the 'PROMPT' and all Vars... (And use your "real" URL for the 'URL_Site' Var in the Script, of course...!)

Pay attention in the 'PROMPT' to the Content for '_{{!COL1}}_', the "_" is used as a Delimiter to still display "stg" if the Var is Empty or Undefined or contains any Spaces/Tabs or (Soft) Returns... which wouldn't be accepted in the URL...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
abrooks
Posts: 2
Joined: Thu Jun 20, 2019 11:51 pm

Re: Seeking to append a number to a single URL and loop activity

Post by abrooks » Sun Jun 23, 2019 6:05 pm

Thank you for the nudge.
Yes, FF 67.X (they update every other day lately).
Win 10 Enterprise 64 bit
I also did have the FF extension a file access installed. In fact, i installed everything the download packages had to offer including the iMacros browser which appears not to render some elements likely because of security policies on my workplace network.

URL GOTO=https://www.whatever.com/{{!COL1}} did work. Thank you for clarifying that. It turns out I had malformatted my own URL hence the errors being returned. I could not provide the actual URL as it is internal to my workplace only, hence the example.com use.

Much appreciated.
chivracq
Posts: 8625
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Seeking to append a number to a single URL and loop activity

Post by chivracq » Sun Jun 23, 2019 10:04 pm

abrooks wrote:
Sun Jun 23, 2019 6:05 pm
Thank you for the nudge.
Yes, FF 67.X (they update every other day lately).
Win 10 Enterprise 64 bit
I also did have the FF extension a file access installed. In fact, i installed everything the download packages had to offer including the iMacros browser which appears not to render some elements likely because of security policies on my workplace network.

URL GOTO=https://www.whatever.com/{{!COL1}} did work. Thank you for clarifying that. It turns out I had malformatted my own URL hence the errors being returned. I could not provide the actual URL as it is internal to my workplace only, hence the example.com use.

Much appreciated.
Ah OK, good to hear then... :D

Notice btw how I used some 'URL_Site' Var for your URL Domain instead of hard-coding your URL everywhere in your Script, especially if you (re)use it several times or want to reuse the same Script for a different Site/Page, then you only need to edit one single Var... (And it's trivial to debug...) :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply