Extracted Values Include Unwanted Labels

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 Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.
Post Reply
bzowk
Posts: 1
Joined: Mon Nov 12, 2018 9:55 pm

Extracted Values Include Unwanted Labels

Post by bzowk » Mon Nov 12, 2018 10:09 pm

Good Afternoon -

I am trying to configure an iMacros job which will collect 2 numerical values from 4 web pages then save them into a CSV daily for import into a report. I've gotten it to mostly work except for one small issue which I need help with, please.

I used the wizard to browse to and select the values, choosing to "Add command" after each. Only the numbers were selected, but the "Extracted" box shows the labels next to the numbers as well. I continued to see what the output would be and once I ran the job, it created a CSV which included both the label and value. Below is a screenshot of just the value "28" selected, yet it shows "Consumed 28 28" in "Extracted." The resulting CSV for that is also ""Consumed 28"
Image

The macro string which captures the data is below.

Code: Select all

TAG POS=1 TYPE=LABEL ATTR=ID:Consumed_label EXTRACT=TXT
I've looked through online help, but cannot figure out how to just get it to grab the numerical value. Any suggestions?

Bonus Question
Once I get this figured out, I will need to find a way to import all 8 extracted values into an existing Excel report. If anyone has any suggestions or links that would help, I'd really appreciate it.

Thank You!
chivracq
Posts: 7722
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extracted Values Include Unwanted Labels

Post by chivracq » Mon Nov 12, 2018 11:57 pm

bzowk wrote:Good Afternoon -

I am trying to configure an iMacros job which will collect 2 numerical values from 4 web pages then save them into a CSV daily for import into a report. I've gotten it to mostly work except for one small issue which I need help with, please.

I used the wizard to browse to and select the values, choosing to "Add command" after each. Only the numbers were selected, but the "Extracted" box shows the labels next to the numbers as well. I continued to see what the output would be and once I ran the job, it created a CSV which included both the label and value. Below is a screenshot of just the value "28" selected, yet it shows "Consumed 28 28" in "Extracted." The resulting CSV for that is also ""Consumed 28"

Image

The macro string which captures the data is below.

Code: Select all

TAG POS=1 TYPE=LABEL ATTR=ID:Consumed_label EXTRACT=TXT
I've looked through online help, but cannot figure out how to just get it to grab the numerical value. Any suggestions?

Bonus Question
Once I get this figured out, I will need to find a way to import all 8 extracted values into an existing Excel report. If anyone has any suggestions or links that would help, I'd really appreciate it.

Thank You!
Yeah, Time is always a relative Concept, your "afternoon" is "evening" already in Europe, ah-ah...! :wink:

FCIM...! :mrgreen: (Read my Sig...)
=> iMB v12.0.501, OS...?
Always mention your FCI clearly when you open a Thread, preferably at the complete beginning of your Post, rather then half hidden in the middle of some Screenshot, I usually don't read/answer otherwise...

Hum, and when posting Images/Screenshots, you can better upload them directly to the Forum, as all those Image Hosting Sites one day stop existing or go commercial or clean up their Servers from time to time and (older) Threads containing such Images end up a bit useless for other Users, with empty Image Containers... :idea:

>>>

But OK, to answer your Qt, I can't see the full Content of the 'HTML code' Box from your Screenshot, but it looks like this 'LABEL' Element contains one or more 'DIV' Elements inside it, possibly without ID and the Wizard selected at the 'LABEL' Level while you'd rather be interested at the 'DIV' Level.

You would then need to try to select/identify the 'DIV' that you only want.
If it can't be identified (reliably) easily, you might need (Double) 'Relative Positioning' using that 'LABEL' as Anchor.

Or using your current 'EXTRACT' Statement, you could use 'EVAL()' on that Extract to keep only the Data that you want.

Post the full (relevant) HTML Code or the URL to that Page or upload some HTML Saveas (zipped, Max 256Kb) to your Thread if you don't come out by yourself.

>>>

Concerning importing your 8 Values into your existing Excel Report, well, you have the iMacros 'SAVEAS' Command that would be able to save that Data into a '.TXT' or '.CSV' File, and will append the Data if the File already exists, and is not already opened in Excel at that moment, for a '.CSV' File for example, as Excel will put a Lock on it and iMacros won't be able to open the File and save the Data...

But that won't work if your Report is a "complex" Report and you want to add the Data into some specific Cell(s)/Column.
An Option could be if you can open (and edit) that Report from some Online Interface, through an Online Form, or as a GoogleSheet for example, that can be accessed from iMacros...

Or you can always open the '.TXT' or '.CSV' File from Excel or Notepad and Copy&Paste its Content into the Report or course, but that's not really an "automated" Solution, ah-ah...!
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
Posts: 7722
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extracted Values Include Unwanted Labels

Post by chivracq » Thu Nov 15, 2018 1:32 am

Hum, not "really" impressed by the Follow-up, 2 days later..., OK, fair enough, but good luck for your further Threads... :shock:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
Posts: 7722
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extracted Values Include Unwanted Labels

Post by chivracq » Thu Nov 15, 2018 11:57 pm

Still no Follow-up but I had stg to add about updating the Excel Report, you are using iMB12 from your FCI, not mentioned if you are using the 'Trial' Version or the 'PE' Version ('Personal Edition'), 'Professional Edition' or the 'Enterprise Edition', but if using the 'Enterprise Edition', you then also have the 'Scripting Interface' and you could then embed some '.vbs'/'.vba' Macro directly in your '.XLS' Report that can handle the iMacros part directly...

More Info:
- 6.1 Updating Excel Data From the Web
(But all Links to Tutorials and further Info on that Wiki Page seem to be a bit dead currently, oops...!, I reported it in this Thread... :cry: )
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Post Reply