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...
(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...