Trying to extract a specific number or character from a body of text rather than the whole line.

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
CTJW1907
Posts: 5
Joined: Fri May 08, 2020 3:33 pm

Trying to extract a specific number or character from a body of text rather than the whole line.

Post by CTJW1907 » Fri Jan 14, 2022 5:10 pm

The all important info -
VERSION BUILD=10101485
OS=macOS Monterey 12.1
Browser=95.0.2 (64-bit)
Other macros functioning as expected=YES

I'd like to my post with an apology, the last time I asked for support I simply gave up but didn't post to say thank you.

I have been furthering my knowledge of iMacro and it's potential functions playing an online text based games. I'm trying to automate the purchase of a product. I think I've tried a variety of different methods and solutions between extracting css selectors, using the clipboard function and caused myself to become more confused.

Code: Select all

SET !EXTRACT_TEST_POPUP NO
URL GOTO=https://awebsite.com/site.php?page=foodhall
' copy required info
TAG POS=2 TYPE=DIV ATTR=TXT:This<SP>foodhall<SP>is<SP>owned<SP>by<SP>Dave<SP>U* EXTRACT=TXT
SET !CLIPBOARD {{!EXTRACT}}
WAIT SECONDS=2
' paste required info
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:https://awebsite.com/site.php?page=foodhall ATTR=NAME:buyfood CONTENT={{!CLIPBOARD}}
WAIT SECONDS=20
' submit
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:https://awebsite.com/site.php?page=foodhall ATTR=NAME:give
WAIT SECONDS=10
The comment out is for my reference :)

The extract function works but I would like some assistance in getting a specific piece of information out of it.
It returns the following -
This foodhall is owned by Harry's Uncle!
And being held by Harry!
It currently has 220 hams.
The bullet price is $1,000 for each ham!
I would like to extract the 220 in this case (the number changes over time) and paste it into a box below it and submit the form.

I can provide the html where this information is found if required.

Any assistance would be greatly appreciated. The forum, program and extensions are fantastic products, I will be purchasing a full license in the near future!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Trying to extract a specific number or character from a body of text rather than the whole line.

Post by chivracq » Fri Jan 14, 2022 5:41 pm

CTJW1907 wrote:
Fri Jan 14, 2022 5:10 pm
The all important info -

Code: Select all

VERSION BUILD=10101485
OS=macOS Monterey 12.1
Browser=95.0.2 (64-bit)
Other macros functioning as expected=YES

I'd like to my post with an apology, the last time I asked for support I simply gave up but didn't post to say thank you.

I have been furthering my knowledge of iMacro and it's potential functions playing an online text based games. I'm trying to automate the purchase of a product. I think I've tried a variety of different methods and solutions between extracting css selectors, using the clipboard function and caused myself to become more confused.

Code: Select all

SET !EXTRACT_TEST_POPUP NO
URL GOTO=https://awebsite.com/site.php?page=foodhall
' copy required info
TAG POS=2 TYPE=DIV ATTR=TXT:This<SP>foodhall<SP>is<SP>owned<SP>by<SP>Dave<SP>U* EXTRACT=TXT
SET !CLIPBOARD {{!EXTRACT}}
WAIT SECONDS=2
' paste required info
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:https://awebsite.com/site.php?page=foodhall ATTR=NAME:buyfood CONTENT={{!CLIPBOARD}}
WAIT SECONDS=20
' submit
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:https://awebsite.com/site.php?page=foodhall ATTR=NAME:give
WAIT SECONDS=10
The comment out is for my reference :)

The extract function works but I would like some assistance in getting a specific piece of information out of it.
It returns the following -
This foodhall is owned by Harry's Uncle!
And being held by Harry!
It currently has 220 hams.
The bullet price is $1,000 for each ham!
I would like to extract the 220 in this case (the number changes over time) and paste it into a box below it and submit the form.

The html where this information is found if required.

Any assistance would be greatly appreciated. The forum, program and extensions are fantastic products, I will be purchasing a full license in the near future!

"I'd like to [start :wink: ] my post with an apology, the last time I asked for support I simply gave up but didn't post to say thank you.":
=> Hum, yep indeed, what you wanted was not "very complicated", you can always pick up the Thread at any moment, if you still want a Solution... :idea:

>>>

Alright, FCI in this one:

Code: Select all

iMacros for FF v10.1.0 'Free', FF95_x64, macOS v12.1.
=> Hum, about: "I will be purchasing a full license in the near future!":
=> Beh..., nope, not "needed", unless you use iMacros for "Business Use", but I don't think that playing a Game qualifies as "Business Use", ah-ah...!, you don't need a 'PE' License, as you are on macOS, but macOS (and Linux) are not supported by the 'PE' Version...

Okay..., what you want is (again, ah-ah...!) not "very complicated", re-ah-ah...!
Many possible Implementations, here is one for example, assuming "ham(s)" is a "Constant", hum, OK, even better, and independent from "ham"...:

Code: Select all

SET !EXTRACT NULL
TAG POS=2 TYPE=DIV ATTR=TXT:This<SP>foodhall<SP>is<SP>owned<SP>by<SP>Dave<SP>U* EXTRACT=TXT
SET !ERRORIGNORE YES
SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('currently has '); y=x[1].split(' '); z=y[0]; z;")
PROMPT EXTRACT:<BR>_{{!EXTRACT}}_<BR><BR>VAR1:<SP>_{{!VAR1}}_
- (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...
CTJW1907
Posts: 5
Joined: Fri May 08, 2020 3:33 pm

Re: Trying to extract a specific number or character from a body of text rather than the whole line.

Post by CTJW1907 » Fri Jan 14, 2022 6:08 pm

Hi, thanks for your response!

I'll look back at my previous thread and see if I need it :)
=> Hum, about: "I will be purchasing a full license in the near future!":
- I shall read up, I was under the impression i'd need a license for file access?

I'm going to read up about the SET !VAR now rather than copying and pasting errors back to you.

I'll be back :)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Trying to extract a specific number or character from a body of text rather than the whole line.

Post by chivracq » Fri Jan 14, 2022 6:43 pm

CTJW1907 wrote:
Fri Jan 14, 2022 6:08 pm
Hi, thanks for your response!

I'll look back at my previous thread and see if I need it :)
=> Hum, about: "I will be purchasing a full license in the near future!":
- I shall read up, I was under the impression i'd need a license for file access?

I'm going to read up about the SET !VAR now rather than copying and pasting errors back to you.

I'll be back :)

Yep, but the 'File Access' Functionality is "currently" (=> v10.1.x for FF/CR) not supported on macOS and Linux, only Win_x32/_x64 is supported as OS.

And yep, it's "better Practice" to use the Built-in '!VAR[1-3]' Vars rather than the OS Clipboard...
- (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