EXTRACT and ONDOWNLOAD

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

Moderators: Community Moderators, iMacros Moderators

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.

EXTRACT and ONDOWNLOAD

by SilverBirch on Thu Aug 17, 2017 3: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)".
SilverBirch
 
Posts: 2
Joined: Wed Aug 16, 2017 6:23 am

Re: EXTRACT and ONDOWNLOAD

by chivracq on Thu Aug 17, 2017 6:38 am

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)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: 6479
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: EXTRACT and ONDOWNLOAD

by SilverBirch on Fri Aug 18, 2017 12: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.
SilverBirch
 
Posts: 2
Joined: Wed Aug 16, 2017 6:23 am

Re: EXTRACT and ONDOWNLOAD

by chivracq on Fri Aug 18, 2017 6:31 am

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)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: 6479
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 3 guests

-->