What script to refresh the page until the item is available

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
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
smashing|
Posts: 4
Joined: Thu May 27, 2021 3:16 am

What script to refresh the page until the item is available

Post by smashing| » Thu May 27, 2021 6:57 am

Hi all ! I'm trying to make a macro/bot for this shopping website so i can get the items i want without siting there clicking all day long. I have been trying to make something in this program where i can have it refresh the page until the item is available then have it add to cart and buy. I want the script to check the page until the item is there and buy it. The page has to refresh a lot because the items sell within 1-3 sec of being posted. Also I want to buy 2 items everytime when it is available.

VERSION BUILD=1011 RECORDER=CR
WAIT SECONDS=1
URL GOTO=https://shopee.com.my/
TAG POS=1 TYPE=BUTTON ATTR=TXT:buy<SP>now
TAG POS=1 TYPE=BUTTON ATTR=TXT:checkout
TAG POS=1 TYPE=SPAN ATTR=TXT:ShopeePay
TAG POS=1 TYPE=BUTTON ATTR=TXT:place<SP>order


So far with the above script , I will always stuck and got the below error msg

RuntimeError: element BUTTON specified by TXT:checkout was not found, line: 5


Appreciate any help. Thank you so much!
Attachments
shopee imacro.png
chivracq
Posts: 9822
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: What script to refresh the page until the item is available

Post by chivracq » Thu May 27, 2021 12:17 pm

smashing| wrote:
Thu May 27, 2021 6:57 am
Hi all ! I'm trying to make a macro/bot for this shopping website so i can get the items i want without siting there clicking all day long. I have been trying to make something in this program where i can have it refresh the page until the item is available then have it add to cart and buy. I want the script to check the page until the item is there and buy it. The page has to refresh a lot because the items sell within 1-3 sec of being posted. Also I want to buy 2 items everytime when it is available.

Code: Select all

VERSION BUILD=1011 RECORDER=CR
WAIT SECONDS=1
URL GOTO=https://shopee.com.my/
TAG POS=1 TYPE=BUTTON ATTR=TXT:buy<SP>now
TAG POS=1 TYPE=BUTTON ATTR=TXT:checkout
TAG POS=1 TYPE=SPAN ATTR=TXT:ShopeePay
TAG POS=1 TYPE=BUTTON ATTR=TXT:place<SP>order

So far with the above script , I will always stuck and got the below error msg

Code: Select all

RuntimeError: element BUTTON specified by TXT:checkout was not found, line: 5

Appreciate any help. Thank you so much!

(F)CIM...! :mrgreen: (Read my Sig...) I "thought" you had read the Forum Rules, but you missed the Section about mentioning your FCI... :(
=> iMacros for CR v10.1.1, 'Free'/'PE'/'Trial'...?, CR90...?, OS...?

>>>

But yep, for your "Scenario", I think you need to enable '!ERRORIGNORE' to "bypass" the "checkout" Button Line when that Button is not present/available/enabled, + to shorten '!TIMEOUT_STEP' to "1" or "0" or your Script will wait for 6 Sec for each Line/'TAG' that doesn't get found... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
smashing|
Posts: 4
Joined: Thu May 27, 2021 3:16 am

Re: What script to refresh the page until the item is available

Post by smashing| » Thu May 27, 2021 3:34 pm

Hi , tq for your reply and sorry that I missed the note . I am very very new with imacros and still not sure what are some of the items mean.

Imacros Version 10.1.0.1485
Browser : Chrome & Firefox
MacOS 11.3.1
IMacros Free version

Anyway , I have altered the script to be as below

VERSION BUILD=10101485
WAIT SECONDS=0
SET !TIMEOUT_STEP 0
SET !ERRORIGNORE YES
URL GOTO=https://shopee.com.my/
TAG POS=1 TYPE=BUTTON ATTR=TXT:buy<SP>now
TAG POS=1 TYPE=BUTTON ATTR=TXT:checkout
TAG POS=1 TYPE=SPAN ATTR=TXT:ShopeePay
TAG POS=1 TYPE=BUTTON ATTR=TXT:place<SP>order

it seems to work well only one issue - i need to change the quantity . the above script only shows 1 item but I need to check out 2 items . how and what line do i add ? Thank you.
chivracq
Posts: 9822
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: What script to refresh the page until the item is available

Post by chivracq » Thu May 27, 2021 5:14 pm

smashing| wrote:
Thu May 27, 2021 3:34 pm
Hi , tq for your reply and sorry that I missed the note . I am very very new with imacros and still not sure what are some of the items mean.

Code: Select all

Imacros Version 10.1.0.1485
Browser : Chrome & Firefox
MacOS 11.3.1
IMacros Free version
Anyway , I have altered the script to be as below

Code: Select all

VERSION BUILD=10101485
WAIT SECONDS=0
SET !TIMEOUT_STEP 0
SET !ERRORIGNORE YES
URL GOTO=https://shopee.com.my/
TAG POS=1 TYPE=BUTTON ATTR=TXT:buy<SP>now
TAG POS=1 TYPE=BUTTON ATTR=TXT:checkout
TAG POS=1 TYPE=SPAN ATTR=TXT:ShopeePay
TAG POS=1 TYPE=BUTTON ATTR=TXT:place<SP>order
it seems to work well only one issue - i need to change the quantity . the above script only shows 1 item but I need to check out 2 items . how and what line do i add ? Thank you.

OK, Thanks for your FCI(s), even if the Browser Versions are still missing for both Browsers, but that will give I reckon:

Code: Select all

- iMacros for CR v10.1.1, 'Free', CR90, macOS v11.3.1.
- iMacros for FF v10.1.0, 'Free', FF88, macOS v11.3.1.
... And on macOS (and Linux), you can only use the 'Free' Versions for both Browsers, there is no 'PE' Version, only for Win32/64...

>>>

Yep well, then, you simply need to record clicking on the "+" Sign to increment the Qtt from "1" to '2", I would think... :idea:
I don't see any "Difficulty"...

The "Buy Now" Button will remain disabled I reckon for "0 piece available" and "1 piece available"...

And if you only want to click on the "+" Sign when you know "for sure" that there are at least 2 Items available, I reckon the "piece" will become "pieces" (Plural) in "4 pieces available" for example, then you could use that "n piece(s) available" Element as 'Anchor' for 'Relative Positioning' for some "basic" Conditional Logic...
=> Stg like:

Code: Select all

[code]VERSION BUILD=10101485
WAIT SECONDS=0
SET !TIMEOUT_STEP 0
SET !ERRORIGNORE YES
URL GOTO=https://shopee.com.my/
'>
'Increment Qtt only if "pieces" is Plural:
TAG POS=1 TYPE=SPAN ATTR=TXT:*<SP>pieces<SP>available
TAG POS=R-1 TYPE=SPAN ATTR=TXT:+
'>
TAG POS=1 TYPE=BUTTON ATTR=TXT:buy<SP>now
TAG POS=1 TYPE=BUTTON ATTR=TXT:checkout
TAG POS=1 TYPE=SPAN ATTR=TXT:ShopeePay
TAG POS=1 TYPE=BUTTON ATTR=TXT:place<SP>order
OK, I'm just guessing with "TYPE=SPAN" and the 'TXT' Attributes, you'll need to record tagging those Fields yourself, I can't reconstruct the HTML Structure of the Page from a Screenshot only...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
smashing|
Posts: 4
Joined: Thu May 27, 2021 3:16 am

Re: What script to refresh the page until the item is available

Post by smashing| » Tue Jun 01, 2021 2:55 am

Imacro Checked Box.jpg
Thank you ! The script helps to increase the total item that i want . Awesome !

However now I am stuck at the next step. It requires me to tick a checkbox (as per below pic) . What is the script for me to check the box

Currently this is my scripts

WAIT SECONDS=0
SET !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
URL GOTO=https://shopee.com.my/-MD-Keto-Lakanto- ... -sweetener
'>
'Increment Qtt only if "pieces" is Plural:
TAG POS=1 TYPE=SPAN ATTR=TXT:*<SP>pieces<SP>available
TAG POS=R-1 TYPE=SPAN ATTR=TXT:+
'>
TAG POS=1 TYPE=BUTTON ATTR=TXT:buy<SP>now
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=TXT:Shopee<SP>Coins CONTENT=YES
TAG POS=1 TYPE=BUTTON ATTR=TXT:checkout
TAG POS=1 TYPE=SPAN ATTR=TXT:ShopeePay
TAG POS=1 TYPE=BUTTON ATTR=TXT:place<SP>order


to be honest , i dont know what is the right line to check a box but i just follow whatever script that i saw in this forum 😅
chivracq
Posts: 9822
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: What script to refresh the page until the item is available

Post by chivracq » Tue Jun 01, 2021 11:22 am

smashing| wrote:
Tue Jun 01, 2021 2:55 am

Code: Select all

Imacro Checked Box.jpg
Thank you ! The script helps to increase the total item that i want . Awesome !

However now I am stuck at the next step. It requires me to tick a checkbox (as per below pic) . What is the script for me to check the box

Currently this is my scripts

Code: Select all

WAIT SECONDS=0
SET !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
URL GOTO=https://shopee.com.my/-MD-Keto-Lakanto-200g-monk-fruit-erythritol-sweetener
'>
'Increment Qtt only if "pieces" is Plural:
TAG POS=1 TYPE=SPAN ATTR=TXT:*<SP>pieces<SP>available
TAG POS=R-1 TYPE=SPAN ATTR=TXT:+
'>
TAG POS=1 TYPE=BUTTON ATTR=TXT:buy<SP>now
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=TXT:Shopee<SP>Coins CONTENT=YES
TAG POS=1 TYPE=BUTTON ATTR=TXT:checkout
TAG POS=1 TYPE=SPAN ATTR=TXT:ShopeePay
TAG POS=1 TYPE=BUTTON ATTR=TXT:place<SP>order

to be honest , i dont know what is the right line to check a box but i just follow whatever script that i saw in this forum 😅

OK, glad incrementing the Nb of Items already works... :D

And for the Checkbox, yeah, well..., simply let iMacros record clicking in that Checkbox... :idea:
=> It will probably record stg like...:

Code: Select all

TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:??? ATTR=NAME:??? CONTENT=YES
... But I cannot guess the "???" parts from a Screenshot...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
smashing|
Posts: 4
Joined: Thu May 27, 2021 3:16 am

Re: What script to refresh the page until the item is available

Post by smashing| » Tue Jun 01, 2021 4:51 pm

once again . thank you for your response !

I am now able to get to the "Pay" page. However since I am playing the script in a loop, whenever I get to the Pay page , it will be loading the Buy page again before I can press the Pay button ( i have to play the macro in a loop since I am waiting until the item is available) .

Is there anyway that I can stop the loop once it reaches the Pay page?

VERSION BUILD=10101485
SET !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
URL GOTO=https://shopee.com.my/
'>
'Increment Qtt only if "pieces" is Plural:
TAG POS=1 TYPE=SPAN ATTR=TXT:*<SP>pieces<SP>available
TAG POS=R-1 TYPE=SPAN ATTR=TXT:+
'>
WAIT SECONDS=1
SET !TIMEOUT_STEP 2
TAG POS=1 TYPE=BUTTON ATTR=TXT:buy<SP>now
SET !TIMEOUT_STEP 1
TAG POS=1 TYPE=BUTTON ATTR=TXT:check<SP>out
TAG POS=1 TYPE=SPAN ATTR=TXT:ShopeePay
TAG POS=1 TYPE=BUTTON ATTR=TXT:place<SP>order
TAG POS=1 TYPE=BUTTON ATTR=TXT:pay
chivracq
Posts: 9822
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: What script to refresh the page until the item is available

Post by chivracq » Tue Jun 01, 2021 11:59 pm

smashing| wrote:
Tue Jun 01, 2021 4:51 pm
once again . thank you for your response !

I am now able to get to the "Pay" page. However since I am playing the script in a loop, whenever I get to the Pay page , it will be loading the Buy page again before I can press the Pay button ( i have to play the macro in a loop since I am waiting until the item is available) .

Is there anyway that I can stop the loop once it reaches the Pay page?

Code: Select all

VERSION BUILD=10101485
SET !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
URL GOTO=https://shopee.com.my/
'>
'Increment Qtt only if "pieces" is Plural:
TAG POS=1 TYPE=SPAN ATTR=TXT:*<SP>pieces<SP>available
TAG POS=R-1 TYPE=SPAN ATTR=TXT:+
'>
WAIT SECONDS=1
SET !TIMEOUT_STEP 2
TAG POS=1 TYPE=BUTTON ATTR=TXT:buy<SP>now
SET !TIMEOUT_STEP 1
TAG POS=1 TYPE=BUTTON ATTR=TXT:check<SP>out
TAG POS=1 TYPE=SPAN ATTR=TXT:ShopeePay
TAG POS=1 TYPE=BUTTON ATTR=TXT:place<SP>order
TAG POS=1 TYPE=BUTTON ATTR=TXT:pay

Hum, OK, your last Post was about some CB (Checkbox) to tick..., that I don't even see in your last Script..., hum OK...(?) :?

Then for your "last" Pb. well, several Possibilities:
Use the 'PAUSE' Command, of 'FAIL_IF_FOUND', or 'EXTRACT' + 'MacroError()', or some 'Conditional Sound' or 'Conditional 'PROMPT'', you have quite a few Options... (... All of them "perfectly" documented in the Wiki or on the Forum, I would think...)

All "Terms" I mention with Single Quotes are Commands from the Wiki or Keywords to be used to search the Forum...:
- Example_1: 'FAIL_IF_FOUND'...
- Example_2: 'Conditional Sound'... :idea:
(And I've already provided/posted a "Solution" for all Scenarios I mentioned..., hum., except 'FAIL_IF_FOUND', I think, which is pure Wiki/Documentation and that I never use myself... (I find 'MacroError()' more "powerful"...!)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 9822
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: What script to refresh the page until the item is available

Post by chivracq » Tue Jun 15, 2021 2:56 pm

For Info, another User with more or less the same Scenario/Requirements, on the same Site...: 8)
- IF ELSE using iMacros on an e-commerce website
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- 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