Issues with EXTRACT (Using Xero software)

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
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
cld21
Posts: 5
Joined: Thu Nov 14, 2019 5:46 pm

Issues with EXTRACT (Using Xero software)

Post by cld21 » Thu Nov 14, 2019 6:05 pm

1. What version of iMacros are you using?
VERSION BUILD=1005

2. What operating system are you using? (please also specify language)
Windows 10

3. Which browser(s) are you using? (include version numbers)
Version 78.0.3904.97 (Official Build) (64-bit)

Hi all,

Hoping you can help. VERY new to this iMacros so forgive my ignorance. I am trying to run a loop of updating bills on the Xero accounting software and have hit an issue with copy/paste text using EXTRACT function. My code (or portion of it ) is below;

Code: Select all

TAG POS=1 TYPE=A ATTR=ID:addNewLineItemButton
TAG POS=1 TYPE=DIV ATTR=ID:ext-gen60
TAG POS=1 TYPE=IMG ATTR=ID:ext-gen63
TAG POS=1 TYPE=DIV ATTR=TXT:011:<SP>Daily<SP>food<SP>sales

TAG POS=1 TYPE=DIV ATTR=TXT:* EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
PROMPT {{!VAR2}}
TAG POS=3 TYPE=DIV ATTR=TXT:1.00
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:frmMain ATTR=ID:ext-comp-1005 CONTENT={{!VAR2}}
SET !EXTRACT NULL#
I am having an issue specifially with the line

Code: Select all

TAG POS=1 TYPE=DIV ATTR=TXT:* EXTRACT=TXT
When I prompt to see what !VAR2 is, the returned text string is almost like it has done a crtl-A of the whole webpage. Am I doing something obviously wrong? Does Xero have stange things imbedded into their text strings that is messing me around?

In short, I am trying to copy one cell of data to another. It is always a number string. Never text.

Thanks for your help
chivracq
Posts: 9494
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Issues with EXTRACT (Using Xero software)

Post by chivracq » Thu Nov 14, 2019 8:39 pm

cld21 wrote:
Thu Nov 14, 2019 6:05 pm

Code: Select all

1. What version of iMacros are you using?
VERSION BUILD=1005

2. What operating system are you using? (please also specify language)
Windows 10

3. Which browser(s) are you using? (include version numbers)
Version 78.0.3904.97 (Official Build) (64-bit)
Hi all,

Hoping you can help. VERY new to this iMacros so forgive my ignorance. I am trying to run a loop of updating bills on the Xero accounting software and have hit an issue with copy/paste text using EXTRACT function. My code (or portion of it ) is below;

Code: Select all

TAG POS=1 TYPE=A ATTR=ID:addNewLineItemButton
TAG POS=1 TYPE=DIV ATTR=ID:ext-gen60
TAG POS=1 TYPE=IMG ATTR=ID:ext-gen63
TAG POS=1 TYPE=DIV ATTR=TXT:011:<SP>Daily<SP>food<SP>sales

TAG POS=1 TYPE=DIV ATTR=TXT:* EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
PROMPT {{!VAR2}}
TAG POS=3 TYPE=DIV ATTR=TXT:1.00
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:frmMain ATTR=ID:ext-comp-1005 CONTENT={{!VAR2}}
SET !EXTRACT NULL#
I am having an issue specifially with the line

Code: Select all

TAG POS=1 TYPE=DIV ATTR=TXT:* EXTRACT=TXT
When I prompt to see what !VAR2 is, the returned text string is almost like it has done a crtl-A of the whole webpage. Am I doing something obviously wrong? Does Xero have stange things imbedded into their text strings that is messing me around?

In short, I am trying to copy one cell of data to another. It is always a number string. Never text.

Thanks for your help

Post approved as you mentioned your FCI, but 'Free'/'PE' is still missing for me to read (and maybe answer)... :idea:
Simplified Format about your FCI is OK:

Code: Select all

iMacros v10.0.5 for CR [Free/PE...?], CR v78.0.3904.97 (64-bit), Win10.
+ Probably wrong Sub-Forum, the 'CR' Sub-Forum is meant for Scripts that work in other Browsers/Versions but specifically fail in one CR Version...
I don't see any Info about other FCI's... (But no need to duplicate... :wink: )
- (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...
cld21
Posts: 5
Joined: Thu Nov 14, 2019 5:46 pm

Re: Issues with EXTRACT (Using Xero software)

Post by cld21 » Fri Nov 15, 2019 11:03 am

Thanks for reply. I am afriad I understand little of your post with all the acroynms. Sorry, new to all this. What is Free/PE?? I am using a free version of imacros if that's what you mean.
chivracq
Posts: 9494
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Issues with EXTRACT (Using Xero software)

Post by chivracq » Fri Nov 15, 2019 1:20 pm

cld21 wrote:
Fri Nov 15, 2019 11:03 am
Thanks for reply. I am afriad I understand little of your post with all the acroynms. Sorry, new to all this. What is Free/PE?? I am using a free version of imacros if that's what you mean.

OK, yep, 'PE' means 'Personal Edition', as the 'Free' Version is "meant" for Home Users while "Xero Accounting Software" (for small Businesses) didn't "sound" like you are a "Home User" to me, but OK, never mind, I don't "care", I just want(ed) to know which Version exactly you are using...

>>>

Then OK, yep normal, concerning your "TAG POS=1 TYPE=DIV ATTR=TXT:* EXTRACT=TXT", this will extract the very first 'DIV' Element of the Page which is probably the Content of the whole Page as you've "removed" the whole 'TXT' Attribute.

In order to tag/identify (and extract) your "specific" Element, you need to use some other Attribute(s), like its Name/Id/Class (or a Combination of those), or try to keep some part(s) of the 'TXT' Attribute, but if for example you are trying to extract the Text of the "011:<SP>Daily<SP>food<SP>sales" Element, chances are stg like the following will still manage to uniquely identify and extract this Element:

Code: Select all

'Recorded:
'TAG POS=1 TYPE=DIV ATTR=TXT:011:<SP>Daily<SP>food<SP>sales
TAG POS=1 TYPE=DIV ATTR=TXT:0*:<SP>* EXTRACT=TXT
+ Maybe have to "play" a bit with the "POS=1" to "POS=2" or "POS=3"...

Another way to identify your Element uniquely is to use 'Relative Positioning' as this Element probably has some "Label" associated with it that you could use as 'Anchor' with "TAG POS=R1" for your Element to Extract, then your "ATTR=TXT"*" would work. :idea:

( :arrow: Terms I use between Single Quotes can be used to search the Wiki and/or the Forum if you need more Info to understand the "Concept"...)

>>>

And the 'iMacros for CR' is indeed "definitely" not the correct Sub-Forum btw... Correct Sub-Forum to open this Thread would have been the 'Data Extraction' Sub-Forum, where your Thread will probably get moved to... :wink:
Try to select the "correct" Sub-Forum when you open a Thread, as several Advanced Users (and also Members of the TechSup Team) only check specific Sub-Forums, depending on our "Expertise"... And those Threads are also easier to find for other Users searching the Forum with a similar Case/Scenario/Qt... :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...
cld21
Posts: 5
Joined: Thu Nov 14, 2019 5:46 pm

Re: Issues with EXTRACT (Using Xero software)

Post by cld21 » Fri Nov 15, 2019 4:19 pm

Thanks very much. V useful and helped me learn how this all works a bit better. I managed to get what I wanted through your help and using SPLIT to extract the exact text string I wanted. Code is below.

Code: Select all

TAG POS=2 TYPE=DIV ATTR=TXT:0*:<SP>* EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !VAR3 EVAL("var s = '{{!VAR2}}'; var x,y,z; y = s.split('1.00'); z = y[1].split('200'); z[0];")
chivracq
Posts: 9494
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Issues with EXTRACT (Using Xero software)

Post by chivracq » Fri Nov 15, 2019 4:43 pm

cld21 wrote:
Fri Nov 15, 2019 4:19 pm
Thanks very much. V useful and helped me learn how this all works a bit better. I managed to get what I wanted through your help and using SPLIT to extract the exact text string I wanted. Code is below.

Code: Select all

TAG POS=2 TYPE=DIV ATTR=TXT:0*:<SP>* EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !VAR3 EVAL("var s = '{{!VAR2}}'; var x,y,z; y = s.split('1.00'); z = y[1].split('200'); z[0];")

Yep, very neat...! :D

Be "aware" that it's more "reliable" to also enable '!ERRORIGNORE', at least just before the 'EVAL()', in case the 'EXTRACT' returns some "#EANF#" (Element not found), because 'EVAL()' "doesn't like" otherwise the 'y[1]' (which won't exist) and your Script will abort... :!:

Good "Exercise" for you would be to also "find the Solution" using the 'Relative Positioning' Method that I mentioned... :wink:
- (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...
cld21
Posts: 5
Joined: Thu Nov 14, 2019 5:46 pm

Re: Issues with EXTRACT (Using Xero software)

Post by cld21 » Sat Nov 16, 2019 7:21 pm

I actually thought I had this working but seem to be running into some consitency issues using LOOP so my code clearly isn't robust enough.

I have tried the relative positioning issues so it is better but it's tricky for me!

Image

https://ibb.co/K6tNfvj

See above. I am trying to copy the 357.50 into where the 1.00 is in the row below.

When I record the code and click on the 357.50 cell it gives me;

Code: Select all

TAG POS=1 TYPE=DIV ATTR=TXT:357.50
As is to be expected. Why, therefore does the following not extract the "357.50"?

Code: Select all

TAG POS=1 TYPE=DIV ATTR=TXT:0*:<SP>* EXTRACT=TXT
It ends up extracting "011: Daily food sales" which is located in the first column. Weird I think. Would love to get help on editing the code I had working in my previous post to use with relative positioning.
chivracq
Posts: 9494
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Issues with EXTRACT (Using Xero software)

Post by chivracq » Sun Nov 17, 2019 4:48 am

cld21 wrote:
Sat Nov 16, 2019 7:21 pm
I actually thought I had this working but seem to be running into some consitency issues using LOOP so my code clearly isn't robust enough.

I have tried the relative positioning issues so it is better but it's tricky for me!

Image

https://ibb.co/K6tNfvj

See above. I am trying to copy the 357.50 into where the 1.00 is in the row below.

When I record the code and click on the 357.50 cell it gives me;

Code: Select all

TAG POS=1 TYPE=DIV ATTR=TXT:357.50
As is to be expected. Why, therefore does the following not extract the "357.50"?

Code: Select all

TAG POS=1 TYPE=DIV ATTR=TXT:0*:<SP>* EXTRACT=TXT
It ends up extracting "011: Daily food sales" which is located in the first column. Weird I think. Would love to get help on editing the code I had working in my previous post to use with relative positioning.

Hum, OK, but can you check the Forum Rules...?, => for an "Explanation/Expectation" about...:
image
https://ibb.co/K6tNfvj
See above.
- (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...
cld21
Posts: 5
Joined: Thu Nov 14, 2019 5:46 pm

Re: Issues with EXTRACT (Using Xero software)

Post by cld21 » Sun Nov 17, 2019 12:07 pm

Apologies, replaced below.
test.png
chivracq
Posts: 9494
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Issues with EXTRACT (Using Xero software)

Post by chivracq » Sun Nov 17, 2019 5:52 pm

cld21 wrote:
Sun Nov 17, 2019 12:07 pm
Apologies, replaced below.

test.png

Yep indeed...! Good...! :wink:

>>>

Okay..., if I understand "correctly" what you want, => extract the "357.50" 'Unit Price' from the 1st Row to paste it into the 2nd Row (and replace the Default "1.00") for a same 'Item', then try stg like the following...:

Code: Select all

'Extract 'Item' Name:
SET !EXTRACT NULL
TAG POS=1 TYPE=DIV ATTR=TXT:0*:<SP>* EXTRACT=TXT
'Store that 'Item' Name in a Temp Var:
SET !VAR1 {{!EXTRACT}}
'>
'Extract 'Unit Price':
SET !EXTRACT NULL
TAG POS=R3 TYPE=DIV ATTR=TXT:* EXTRACT=TXT
'Store that 'Unit Price' in a Temp Var:
SET !VAR2 {{!EXTRACT}}
'>
'Debug:
PROMPT Item:<SP>_{{!VAR1}}_<BR>Unit_Price:<SP>_{{!VAR2}}_

'Paste 'Unit Price' from 1st Row into 2nd Row with same 'Item' Name:
TAG POS=2 TYPE=DIV ATTR=TXT:{{!VAR1}}
TAG POS=R1 TYPE=INPUT:TEXT FORM=ID:frmMain ATTR=ID:ext-comp-1005 CONTENT={{!VAR2}}
Not tested of course, and I can't be sure about the "R3" and "R1" as I can't "completely guess" the HTML Structure of that Table from a Screenshot only, the "R3" might become "R5" or "R6" if there are 2 'DIV' Elements per Cell, and the "R1" might become "R3" if all Cells share the same "ID:ext-comp-1005", my "R1" for the Paste is based on the Assumption that all Cells from a same Col share a same ID, and that all Cols have a different ID, but that could be incorrect... :P
- (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