Extract Gift Card Balance

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
TroyDWhite
Posts: 5
Joined: Wed Jun 25, 2008 1:32 pm
Location: Washington, DC

Extract Gift Card Balance

Post by TroyDWhite » Wed Feb 22, 2017 2:03 am

I'm working on an iMacros that

* Checks the balance of a gift card
* Extracts that balance into a spreadsheet

I'm using a 3 column CSV (datasource):

* Card #
* Exp date
* PIN

A new tab is opened for each line of datasource.

I would like to extract the balance into the original datasource, so that the new CSV would have 4 columns:

* Card #
* Exp date
* PIN
* Balance

I know I could extract it into a separate CSV, then paste it back into my original datasource, but I'd prefer to skip this extra step and have everything in one file.

Here is the incomplete code so far; I haven't added a destination for the extraction yet, b/c I'm hoping to add it back to the datasource - if that's even possible.

Code: Select all

VERSION BUILD=5010424 RECORDER=CR
' Check the balance of a Simon Gift Card. Prompts for the Captcha, submits and opens a new tab to check the next gift card balance.
' This method is useful if you have a # of cards to check: the balance will load in the background as another tab opens and checks the next card.
' Once it finishes the spreadsheet, visit each tab to see the balance on your card.
' Feel free to modify and adapt this script.
SET !DATASOURCE SimonGiftCards.csv 
SET !DATASOURCE_COLUMNS 3
SET !VAR1 2
SET !LOOP {{!VAR1}}
SET !DATASOURCE_LINE {{!LOOP}} 
SET !ERRORIGNORE YES
URL GOTO=https://www.simon.com/giftcard/card_balance.aspx
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_FullContent_MainContent_tbNumber CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_FullContent_MainContent_tbExpDate CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_FullContent_MainContent_tbCid CONTENT={{!COL3}}
' The Captcha was covered by the dialog box, so added a new position tag to move the webpage back to the top.
TAG POS=1 TYPE=SECTION ATTR=TXT:The<SP>Simon<SP>Giftcard®<SP>Gift<SP>Card<SP>Corporate<SP>Sa*
PROMPT "Captcha:" !VAR3
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_FullContent_MainContent_CaptchaCodeTextBox CONTENT={{!VAR3}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_FullContent_MainContent_checkBalanceSubmit
' Wait for the results page to open with the balance of the gift card.
WAIT SECONDS=20
' Extract the balance of the gift card 
TAG POS=1 TYPE=SPAN ATTR=ID:ctl00_ctl00_FullContent_MainContent_lblBalance EXTRACT=TXT
WAIT SECONDS=20
TAB OPEN
TAB T={{!LOOP}}
SET !VAR2 {{!LOOP}}
ADD !VAR2 -{{!VAR1}}
ADD !VAR2 2
TAB T={{!VAR2}}
FCIM:
VERSION BUILD=5010424 RECORDER=CR
Mac OS X 10.12.3 (16D32)
Chrome Version 56.0.2924.87 (64-bit) - also use Chrome Canary and Firefox
Included demos work
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract Gift Card Balance

Post by chivracq » Wed Feb 22, 2017 2:54 am

TroyDWhite wrote:FCIM:

Code: Select all

VERSION BUILD=5010424 RECORDER=CR
Mac OS X 10.12.3 (16D32)
Chrome Version 56.0.2924.87 (64-bit) - also use Chrome Canary and Firefox
Included demos work
I'm working on an iMacros that

* Checks the balance of a gift card
* Extracts that balance into a spreadsheet

I'm using a 3 column CSV (datasource):

Code: Select all

* Card #
* Exp date
* PIN
A new tab is opened for each line of datasource.

I would like to extract the balance into the original datasource, so that the new CSV would have 4 columns:

Code: Select all

* Card #
* Exp date
* PIN
* Balance
I know I could extract it into a separate CSV, then paste it back into my original datasource, but I'd prefer to skip this extra step and have everything in one file.

Here is the incomplete code so far; I haven't added a destination for the extraction yet, b/c I'm hoping to add it back to the datasource - if that's even possible.

Code: Select all

VERSION BUILD=5010424 RECORDER=CR
' Check the balance of a Simon Gift Card. Prompts for the Captcha, submits and opens a new tab to check the next gift card balance.
' This method is useful if you have a # of cards to check: the balance will load in the background as another tab opens and checks the next card.
' Once it finishes the spreadsheet, visit each tab to see the balance on your card.
' Feel free to modify and adapt this script.
SET !DATASOURCE SimonGiftCards.csv 
SET !DATASOURCE_COLUMNS 3
SET !VAR1 2
SET !LOOP {{!VAR1}}
SET !DATASOURCE_LINE {{!LOOP}} 
SET !ERRORIGNORE YES
URL GOTO=https://www.simon.com/giftcard/card_balance.aspx
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_FullContent_MainContent_tbNumber CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_FullContent_MainContent_tbExpDate CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_FullContent_MainContent_tbCid CONTENT={{!COL3}}
' The Captcha was covered by the dialog box, so added a new position tag to move the webpage back to the top.
TAG POS=1 TYPE=SECTION ATTR=TXT:The<SP>Simon<SP>Giftcard®<SP>Gift<SP>Card<SP>Corporate<SP>Sa*
PROMPT "Captcha:" !VAR3
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_FullContent_MainContent_CaptchaCodeTextBox CONTENT={{!VAR3}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ctl00_FullContent_MainContent_checkBalanceSubmit
' Wait for the results page to open with the balance of the gift card.
WAIT SECONDS=20
' Extract the balance of the gift card 
TAG POS=1 TYPE=SPAN ATTR=ID:ctl00_ctl00_FullContent_MainContent_lblBalance EXTRACT=TXT
WAIT SECONDS=20
TAB OPEN
TAB T={{!LOOP}}
SET !VAR2 {{!LOOP}}
ADD !VAR2 -{{!VAR1}}
ADD !VAR2 2
TAB T={{!VAR2}}
"FCIM", ah-ah...!, the "M" stands for "Missing", oops...! But OK, just kidding...
Hum, except that v5.0.1 for CR is a Legacy Version, ah-ah...!, I would be interested how you got it to work on CR56..., OK, I guess you are using v8.4.4 for CR...

But hum, if you joined the Forum already in 2008, you are definitely one of the oldest Users on this Forum, ah-ah...! :shock:
Pity we don't see you more often on the Forum, you should be able to answer most Threads I would think, ah-ah...! 8)

Huuuuummmm..., how many Rows are we talking...?
Oh yeah, and is it just for "once in a lifetime" Operation or are you going to reuse that Macro to "recreate"/"edit" regularly your '.CSV' File...? (Because you would then need the 'FILEDELETE' Command, which is not supported on CR...)

It is not possible to directly read and re-write from/to the same '.CSV' and to modify existing Rows to modify Data or add extra Cells to existing Rows, you can only append new Rows (in the Format that you want)..., but there are a few ways to do what you want..., and the easiest will be to read your existing '.CSV' Row by Row, do your extra-Extraction and then recreate a new '.CSV' with the same or new Data in the Format that you want...

Another Option is to have your '.CSV' as a GoogleDoc to which you can add Data/Cells/an extra Column and your Macro can read from it and write to it from a second Tab... Works smooth from CR actually, a few Users on the Forum moved to iMacros for CR for this Reason... :idea:
- (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...
TroyDWhite
Posts: 5
Joined: Wed Jun 25, 2008 1:32 pm
Location: Washington, DC

Re: Extract Gift Card Balance

Post by TroyDWhite » Wed Feb 22, 2017 11:30 am

I'll read the FCIM acronyms more closely next time :D
Another Option is to have your '.CSV' as a GoogleDoc to which you can add Data/Cells/an extra Column and your Macro can read from it and write to it from a second Tab... Works smooth from CR actually, a few Users on the Forum moved to iMacros for CR for this Reason... :idea:
I would be very, very interested in the GDocs option, even if it isn't the easiest. I actually have my virtual assistant entering the card data into a GSheet, which I then download to the Datasources folder and run the script.

Can you suggest how to configure the iMacro?

By the way, I'm also comfortable using FF for my iMacros. :)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract Gift Card Balance

Post by chivracq » Wed Feb 22, 2017 4:51 pm

TroyDWhite wrote:I'll read the FCIM acronyms more closely next time :D
Another Option is to have your '.CSV' as a GoogleDoc to which you can add Data/Cells/an extra Column and your Macro can read from it and write to it from a second Tab... Works smooth from CR actually, a few Users on the Forum moved to iMacros for CR for this Reason... :idea:
I would be very, very interested in the GDocs option, even if it isn't the easiest. I actually have my virtual assistant entering the card data into a GSheet, which I then download to the Datasources folder and run the script.

Can you suggest how to configure the iMacro?

By the way, I'm also comfortable using FF for my iMacros. :)
Well, for the GoogleDocs Solution, search the Forum with "GoogleDoc(s)"/"GoogleSheet"/"GoogleForm", you will find several interesting Threads, I remember some other Advanced User posting some Code/Method to use with GoogleForms, that could be interesting for you as well...
But the Principle is simple, you simply open your GoogleSheet in a second Tab in your Browser and your Macro will switch between Tab_1 and Tab_2 like if they were "standard" Web Pages...

For the first Approach, you can have a look at the following Thread for example, using a '.js' Script on FF:
- Saving to and importing strings from local text file
- (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...
Post Reply