EXTRACT and ONDOWNLOAD

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
SilverBirch
Posts: 8
Joined: Wed Aug 16, 2017 1:23 pm

EXTRACT and ONDOWNLOAD

Post by SilverBirch » Thu Aug 17, 2017 10:06 am

Hello folks!
Windows 7, iMacros for Firefox 8.9.7, Firefox 54.0.1 (32-bit)

I'm an iMacros beginner and I need your help.

I want to extract description of a file and then present it in a message box, after the file is downloaded.
I used EXTRACT=TXT command, but because of this command, iMacro doesn't download the file anymore:

Code: Select all

TAB T=1
URL GOTO=http://tcmb.gov.tr/wps/wcm/connect/TCMB+EN/TCMB+EN/Main+Menu/STATISTICS/Tendency+Surveys/Business+Tendency+Statistics+and+Real+Sector+Confidence+Index/Data
ONDOWNLOAD FOLDER=C:\Temp\ FILE=BTS-ReportTable-Int.xls WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Business<SP>Tendency<SP>Survey<SP>and<SP>Real<SP>Sector* EXTRACT=TXT
prompt File:<SP>{{!EXTRACT}}<SP>downloaded!
I doubled the entry (one without that EXTRACT=TXT command) and now it works:

Code: Select all

TAB T=1
URL GOTO=http://tcmb.gov.tr/wps/wcm/connect/TCMB+EN/TCMB+EN/Main+Menu/STATISTICS/Tendency+Surveys/Business+Tendency+Statistics+and+Real+Sector+Confidence+Index/Data
ONDOWNLOAD FOLDER=C:\Temp\ FILE=BTS-ReportTable-Int.xls WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Business<SP>Tendency<SP>Survey<SP>and<SP>Real<SP>Sector*
TAG POS=1 TYPE=A ATTR=TXT:Business<SP>Tendency<SP>Survey<SP>and<SP>Real<SP>Sector* EXTRACT=TXT
prompt File:<SP>{{!EXTRACT}}<SP>downloaded!
It's just, I don't think it is supposed to look that way.
I'd like to write codes as good as possible.
Could you possibly tell me how my code should look like?

Plus, is it possible to present just a part of extracted text?
I mean in this case: instead of prompting whole "Business Tendency Survey and Real Sector Confidence Index (July 2017)" iMacro would prompt just "(July 2017)".
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EXTRACT and ONDOWNLOAD

Post by chivracq » Thu Aug 17, 2017 1:38 pm

SilverBirch wrote:Hello folks!

Code: Select all

Windows 7, iMacros for Firefox 8.9.7, Firefox 54.0.1 (32-bit)
I'm an iMacros beginner and I need your help.

I want to extract description of a file and then present it in a message box, after the file is downloaded.
I used EXTRACT=TXT command, but because of this command, iMacro doesn't download the file anymore:

Code: Select all

TAB T=1
URL GOTO=http://tcmb.gov.tr/wps/wcm/connect/TCMB+EN/TCMB+EN/Main+Menu/STATISTICS/Tendency+Surveys/Business+Tendency+Statistics+and+Real+Sector+Confidence+Index/Data
ONDOWNLOAD FOLDER=C:\Temp\ FILE=BTS-ReportTable-Int.xls WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Business<SP>Tendency<SP>Survey<SP>and<SP>Real<SP>Sector* EXTRACT=TXT
prompt File:<SP>{{!EXTRACT}}<SP>downloaded!
I doubled the entry (one without that EXTRACT=TXT command) and now it works:

Code: Select all

TAB T=1
URL GOTO=http://tcmb.gov.tr/wps/wcm/connect/TCMB+EN/TCMB+EN/Main+Menu/STATISTICS/Tendency+Surveys/Business+Tendency+Statistics+and+Real+Sector+Confidence+Index/Data
ONDOWNLOAD FOLDER=C:\Temp\ FILE=BTS-ReportTable-Int.xls WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Business<SP>Tendency<SP>Survey<SP>and<SP>Real<SP>Sector*
TAG POS=1 TYPE=A ATTR=TXT:Business<SP>Tendency<SP>Survey<SP>and<SP>Real<SP>Sector* EXTRACT=TXT
prompt File:<SP>{{!EXTRACT}}<SP>downloaded!
It's just, I don't think it is supposed to look that way.
I'd like to write codes as good as possible.
Could you possibly tell me how my code should look like?

Plus, is it possible to present just a part of extracted text?
I mean in this case: instead of prompting whole "Business Tendency Survey and Real Sector Confidence Index (July 2017)" iMacro would prompt just "(July 2017)".
Wow...!, Compliment on the Quality of your Post, with FCI mentioned, Script and URL and what you've tried... Perfect... :D :!:
(It is so "rare" that I had to mention it, ah-ah...! And that kind of Quality motivates nicely other (Advanced) Users to want to help you...!)

Well, about "I doubled the entry (one without that EXTRACT=TXT command) and now it works...", yep, that's correct, that's the way to go...
I would only swap your 2 Statements, ie put the one with the 'EXTRACT' as first... Both "Combinations" work in this case because the Link triggers a Download and remains on the Page, but your "Order" wouldn't work otherwise if the Link was taking you to some other Page...

To only keep "(July 2017)" from the 'EXTRACT' on the Link, yep..., easy to isolate using 'EVAL()' and 'split()' for example:

Code: Select all

TAB T=1
URL GOTO=http://tcmb.gov.tr/wps/wcm/connect/TCMB+EN/TCMB+EN/Main+Menu/STATISTICS/Tendency+Surveys/Business+Tendency+Statistics+and+Real+Sector+Confidence+Index/Data

SET !EXTRACT NULL
TAG POS=1 TYPE=A ATTR=TXT:Business<SP>Tendency<SP>Survey<SP>and<SP>Real<SP>Sector* EXTRACT=TXT
'=> Extracted: "Business Tendency Survey and Real Sector Confidence Index (July 2017)"
SET Report_Date EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split(' ('); z='('+x[1]; z;")
'>
ONDOWNLOAD FOLDER=C:\Temp\ FILE=BTS-ReportTable-Int.xls WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Business<SP>Tendency<SP>Survey<SP>and<SP>Real<SP>Sector*
WAIT SECONDS=1

'promp File:<SP>{{!EXTRACT}}<SP>downloaded!
PROMPT File:<SP>{{Report_Date}}<SP>downloaded!
I took for granted that " (" is always for the Date at the end of the String, and there is always only 1 Set of Parenthesis...

If there might be some other Parenthesis in the Link, you would need to use 'lastIndexOf()' on the '(' + 'subStr()', or to compute the "1" in "x[1]" based on the 'length' Property of the Array returned by the 'split()' like...:

Code: Select all

SET Report_Date EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split(' ('); y=(x.length)-1; z='('+x[y]; z;")
Yep, they both work...! (Tested on iMacros for FF v8.8.2, Pale Moon v26.3.3 (=FF47), Win10-x64.)
The 2nd Solution should then be more "reliable" than the 1st one and would handle the Case if there are multiple Sets of Parenthesis in the Link...
- (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...
SilverBirch
Posts: 8
Joined: Wed Aug 16, 2017 1:23 pm

Re: EXTRACT and ONDOWNLOAD

Post by SilverBirch » Fri Aug 18, 2017 7:26 am

I swapped the two statements and it still works. Cool.
I'll need to study that EVAL thing, 'cause right now I don't know what's going on. :)
Anyway, thank you for your help, chivracq!

P.S. Is there a way to set a line break in a PROMPT statement?
Like <BR> or something?
I can't find this information anywhere.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EXTRACT and ONDOWNLOAD

Post by chivracq » Fri Aug 18, 2017 1:31 pm

SilverBirch wrote:I swapped the two statements and it still works. Cool.
I'll need to study that EVAL thing, 'cause right now I don't know what's going on. :)
Anyway, thank you for your help, chivracq!

P.S. Is there a way to set a line break in a PROMPT statement?
Like <BR> or something?
I can't find this information anywhere.
Well..., I had already swapped the 2 Statements in the Script I posted in my previous Reply, and I had tested that it worked...

Yep, "<SP>" for Space and "<BR>" for Line Break in a 'PROMPT' or 'MacroError()'...
- (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...
SilverBirch
Posts: 8
Joined: Wed Aug 16, 2017 1:23 pm

Re: EXTRACT and ONDOWNLOAD

Post by SilverBirch » Tue Jan 15, 2019 9:56 am

Thank you for your help, chivracq. :)
Post Reply