Download File in -silent mode

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.

Download File in -silent mode

by Gutt on Wed Nov 29, 2017 8:17 am

iMacros V12.0.501.6698
Windows 10 Pro
Purchased Enterprise Edition
Ran in chrome Version 63.0.3239.52 (Official Build) beta (64-bit)



Hi, I have set up an imacros vb script to login to a site and download a file - it is working when browser is being ran normally, but when I run it in -silent mode, which is what i would like to do, it is not able to download the file. I am unable to share the website.

ive got the full script running in chrome. When I run the script in silent mode it does download a file but the file is named "download" -- which is the text of the download button, and contains this message:

Code: Select all
  <div class="container-fluid">   
     <div class="tab-content">
     <br />
        <div class="col-lg-12">
           <div class="row">
              <div class="well">   
                 <center><b><font color="red"> An error has occurred:</font></b></center>
                 <center><i> Request not supported this way. </i></center><br />
                 <p>If you believe your request is valid, please try to submit the request later. </p>
                 <p>If that does not work please contact [CLIENT at 1-800-CLIENT NUMBER]. You will be asked for the details on
                 your computing environment, error information, how to reproduce it, and your contact information.</p>
                 <br />
                 <button class="btn btn-primary" onclick="history.back()">Back to Previous Page</button>
           </div>
         </div>
       </div>   
     <br />

     </div>
 </div> 
     <script src="/MailBoxWebService/resources/dist/js/jquery-1.11.0.min.js"></script>
     <script src="/MailBoxWebService/resources/dist/js/bootstrap.min.js"></script>   
</body>


The part of the script that is downloading the file is the td[6] in the below. I have tried this using the imacros browser, ie, and chrome --

Does anyone know how I can get this to download in silent mode? I am open to using any browser.

Code: Select all
                Set M = Nothing
                Skip = False
                Browser = iim1.iimInit("", True, 300)
                Browser = iim1.iimSet("Count", Count)
                WScript.Echo("Beginning Loop for File Info and File Download. Current Loop = " & Count & "Of" & Total)
                    M = "CODE:"
                    M = "VERSION BUILD=844 RECORDER=CR" + N
                    M = M + "SET !PLAYBACKDELAY 0.00" + N
                    M = M + "SET !var1 {{Count}}" + N
                    M = M + "TAB T=1" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[2] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[3] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[4] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[5] EXTRACT=TXT" + N
                    M = M + "ONDOWNLOAD FOLDER=C:\Temp FILE=* WAIT=YES" + N
                    M = M + "WAIT SECONDS=2" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[6]/a" + N
                    M = M + "WAIT SECONDS=5" + N
                    M = M + "SET !TIMEOUT_STEP 60" + N
                Browser = iim1.iimPlayCode(M)
                FileName = iim1.iimGetLastExtract(1)
                FileDate = iim1.iimGetLastExtract(2)
                FileSize = iim1.iimGetLastExtract(3)
                FileIteration= iim1.iimGetLastExtract(4)     


the html for the "download" element is
Code: Select all
<a href="#" class="btn btn-primary" onclick="downloadFile('rebrkso/.history/REBRKSO.RECAIFPL.J2017333.N06019018951513.2017-11-29.0410','REBRKSO','REBRKSO.RECAIFPL.J2017333.N06019018951513');">Download</a>



the full script is


Code: Select all
Option Explicit

Const iM_ElementNotFound        = -1300
Const iM_EndOfFile              = -1240
Const iM_EvalError              = -1340
Const iM_BrowzConnErr           = -1340
Const iM_BadParam               = -1200
Const iM_Success                = 1
Const ForAppending              = 8
Const OpenAsASCII               = 0
Const CreateIfNotExist          = True

Dim Count, Date, Extract, FileName, FileDate, FileSize, FileIteration, i, iMacros, M, objFile, Processed, Skip, FileInfo

Dim WshShell    : Set WshShell  = CreateObject("WScript.Shell")
Dim iim1        : Set iim1      = CreateObject("iMacros")
Dim Browser     : Browser       = iim1.iimOpen("-cr", true)
Dim objFso      : Set objFso    = CreateObject("Scripting.FileSystemObject")
Dim iDayNumber  : iDayNumber    = DateDiff("d", CDate("1/1/" & Year(Now)), Now) + 1
Dim varLMonth   : varLMonth     = Month(Now) - 1
Dim varDateFull : varDateFull   = Month(Now) & "-" & Day(Now) & "-" & Year(Now)
Dim varOldPW    : varOldPW      = "Client" & Year(Now) & varLMonth
Dim Output      : Output        = "C:\temp\Output" & "_" & varDateFull & ".csv"
Dim LogName     : LogName       = "C:\temp\Client1 iMacros Error log" & varDateFull & ".txt"
Dim DateSearch  : DateSearch    = "J" & Year(Now) & iDayNumber
Dim CountString : CountString   = "Default"
Dim Total       : Total         = "Default"
Dim FirstRun    : FirstRun      = "True"
Dim NewMonth    : NewMonth      = "False"
Dim N           : N             = vbNewLine

    If Len(Day(Now))    =   1   Then varDay         = "0" & varDay
    If Len(Month(Now))  =   1   Then varMonth       = "0" & varMonth
    If Day(Now)         =   1   Then FirstOfMonth   = "True"

    If objFSO.FileExists(Output) Then
        Set Output = objFSO.OpenTextFile(Output, ForAppending, OpenAsASCII)
        FirstRun = False
    Else
        Set Output = objFSO.CreateTextFile(Output, ForAppending, OpenAsASCII)
        If Err <> 0 Then
        End If
    End If
        Browser = iim1.iimSet("DateSearch", DateSearch)
        Browser = iim1.iimSet("varOldPW", varOldPW)
       
            M = "CODE:"
            M = "VERSION BUILD=844 RECORDER=CR" + N
            M = M + "TAB T=1" + N
            M = M + "TAB CLOSEALLOTHERS" + N
            M = M + "URL GOTO=https://www.website.com/" + N
            M = M + "TAG SELECTOR=#httpd_username CONTENT=username" + N
            M = M + "TAG SELECTOR=#loginButton" + N
            M = M + "SET !ENCRYPTION NO" + N
                If NewMonth = "False" Then 
                    M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:httpd_password CONTENT=Password{{!NOW:yyyymm}}" + N
                    M = M + "WAIT SECONDS=1" + N
                    M = M + "TAG SELECTOR=#loginButton" + N
                Else
                    M = M + "TAG SELECTOR=#httpd_password CONTENT=password{{varOldPW}}" + N
                    M = M + "ONDIALOG POS=1 BUTTON=OK CONTENT=" + N
                    M = M + "TAG SELECTOR=#httpd_username CONTENT=username" + N
                    M = M + "TAG SELECTOR=#loginButton" + N
                    M = M + "TAG XPATH=""//*[@id='home']/div[3]/div/div/input" + N
                    M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:currentPassword CONTENT={{varOldPw}}" + N
                    M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:newPassword CONTENT={{!NOW:yyyymm}}" + N
                    M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:confirmPassword CONTENT={{!NOW:yyyymm}}" + N
                    M = M + "TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:changepassword" + N
                    M = M + "TAG SELECTOR=#serviceList>A>IMG" + N
                    M = M + "URL GOTO=https://website.com/MailBoxWebService/webmailbox/home" + N
                End If
            M = M + "WAIT SECONDS=2" + N
            M = M + "TAG SELECTOR=""#serviceList>A>IMG""" + N
            M = M + "TAG POS=1 TYPE=B ATTR=TXT:Mail<SP>Box" + N
            M = M + "TAG POS=1 TYPE=A ATTR=TXT:MyCompany<SP>and<SP>MyCompany<SP>Outbox<SP>(REBRKSO)" + N
            M = M + "SET !TIMEOUT_PAGE 180" + N
            M = M + "SET !TIMEOUT_STEP 100" + N
            M = M + "EVENT TYPE=CLICK SELECTOR=""HTML>BODY>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>FORM>DIV>DIV:nth-of-type(2)>LABEL>INPUT"" BUTTON=0" + N
            M = M + "EVENTS TYPE=KEYPRESS SELECTOR=""HTML>BODY>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>FORM>DIV>DIV:nth-of-type(2)>LABEL>INPUT"" CHARS=""{{DateSearch}}""" + N
            'M = M + "TAG POS=1 TYPE=INPUT:SEARCH FORM=NAME:downloadFiles ATTR=* CONTENT={{DateSearch}}" + N
            M = M + "TAG SELECTOR=#file_details_info EXTRACT=TXT" + N
            M = M + "SET !TIMEOUT_STEP 25" + N
        Browser = iim1.iimPlayCode(M)
        CountString = iim1.iimGetLastExtract(1)
        Total = trim(split(CountString, " ")(5))
            For Count = 1 to Total
                Set M = Nothing
                Skip = False
                Browser = iim1.iimInit("", True, 300)
                Browser = iim1.iimSet("Count", Count)
                WScript.Echo("Beginning Loop for File Info and File Download. Current Loop = " & Count & "Of" & Total)
                    M = "CODE:"
                    M = "VERSION BUILD=844 RECORDER=CR" + N
                    M = M + "SET !PLAYBACKDELAY 0.00" + N
                    M = M + "SET !var1 {{Count}}" + N
                    M = M + "TAB T=1" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[2] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[3] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[4] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[5] EXTRACT=TXT" + N
                    M = M + "ONDOWNLOAD FOLDER=C:\Temp FILE=* WAIT=YES" + N
                    M = M + "WAIT SECONDS=2" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[6]/a" + N
                    M = M + "WAIT SECONDS=5" + N
                    M = M + "SET !TIMEOUT_STEP 60" + N
                Browser = iim1.iimPlayCode(M)
                FileName = iim1.iimGetLastExtract(1)
                FileDate = iim1.iimGetLastExtract(2)
                FileSize = iim1.iimGetLastExtract(3)
                FileIteration= iim1.iimGetLastExtract(4)                               
                Wscript.Echo("File Name = " & FileName)
                Wscript.Echo("File Date = " & FileDate)
                Wscript.Echo("File Size = " & FileSize)
                Wscript.Echo("File Iteration = " & FileIteration)
                If objFSO.FileExists(FileName) Then
                    Count = Count + 1
                Else
                    If Browser = iM_Success Then
                        FileInfo = FileName & "," & FileDate & "," & FileSize & "," & FileIteration
                        Count = Count + 1
                        Output.Write(FileInfo) & vbCrLf
                    ElseIf Browser = iM_BadParam Then
                        Count = Count + 1
                        FileInfo = iim1.iimGetLastExtract(1)
                    Else
                    End If
                End If
            Next
        Set M  = Nothing
        Browser = iim1.iimInit("-cr", false, 300)
        Browser = iim1.iimSet("Count", Count)
            M = "CODE:"
            M = "VERSION BUILD=844 RECORDER=CR" + N
            M = M + "TAG POS=1 TYPE=INPUT:SEARCH ATTR=ARIA-CONTROLS:file_details" + N
            M = M + "TAG POS=1 TYPE=H4 ATTR=TXT:Files<SP>Available<SP>for<SP>Download<SP>under<SP>mailbox<SP>REBRKSO" + N
            M = M + "TAG POS=1 TYPE=A ATTR=TXT:Account" + N
            M = M + "TAG POS=1 TYPE=SPAN ATTR=CLASS:glyphicon<SP>glyphicon-log-out" + N
        Browser = iim1.iimPlayCode(M)
    Output.Close                                                        'Close the CSV File
    Browser = iim1.iimExit()                                            'Close the Browser
    WScript.Echo("Data Extracted : " & FileInfo)
    If Count <> Total Then WScript.Echo("Proceeding to next iteration (" & Count & ")")
    If Count = Total Then WScript.Echo("All iterations completed (" & Count & ")" & N & "Closing browser, input file & output file) ")
    If Browser < 0  then                                                'If there is an error, take a screenshot, send email, and stop processing
        Browser = iim1.iimTakeBrowserScreenshot ("./screenshot of Discover Error  "  & Hour(Now)&Minute(Now)&Second(Now) & ".png")
        Output.Close   
        Browser = iim1.iimExit()
        If iscr  < 0 then
                                                                        'Need to Send an Email     
        End If
    End If
    WScript.Echo(vbNewLine & "------------ Processing Complete ------------")
    WScript.Quit()
   



Thanks for any help!
Last edited by Gutt on Wed Nov 29, 2017 10:12 am, edited 1 time in total.
Gutt
 
Posts: 5
Joined: Thu Nov 16, 2017 11:41 am

Re: Download File in -silent mode

by chivracq on Wed Nov 29, 2017 9:57 am

Gutt wrote:
Code: Select all
iMacros V12.0.501.6698
Purchased Enterprise Edition
Ran in chrome Version 63.0.3239.52 (Official Build) beta (64-bit)


Hi, I have set up an imacros vb script to login to a site and download a file - it is working when browser is being ran normally, but when I run it in -silent mode, which is what i would like to do, it is not able to download the file. I am unable to share the website.

ive got the full script running in chrome. When I run the script in silent mode it does download a file but the file is named "download" -- which is the text of the download button, and contains this message:

Code: Select all
  <div class="container-fluid">   
     <div class="tab-content">
     <br />
        <div class="col-lg-12">
           <div class="row">
              <div class="well">   
                 <center><b><font color="red"> An error has occurred:</font></b></center>
                 <center><i> Request not supported this way. </i></center><br />
                 <p>If you believe your request is valid, please try to submit the request later. </p>
                 <p>If that does not work please contact [CLIENT at 1-800-CLIENT NUMBER]. You will be asked for the details on
                 your computing environment, error information, how to reproduce it, and your contact information.</p>
                 <br />
                 <button class="btn btn-primary" onclick="history.back()">Back to Previous Page</button>
           </div>
         </div>
       </div>   
     <br />

     </div>
 </div> 
     <script src="/MailBoxWebService/resources/dist/js/jquery-1.11.0.min.js"></script>
     <script src="/MailBoxWebService/resources/dist/js/bootstrap.min.js"></script>   
</body>


The part of the script that is downloading the file is the td[6] in the below. I have tried this using the imacros browser, imacros, and chrome --

Does anyone know how I can get this to download in silent mode? I am open to using any browser.

Code: Select all
                Set M = Nothing
                Skip = False
                Browser = iim1.iimInit("", True, 300)
                Browser = iim1.iimSet("Count", Count)
                WScript.Echo("Beginning Loop for File Info and File Download. Current Loop = " & Count & "Of" & Total)
                    M = "CODE:"
                    M = "VERSION BUILD=844 RECORDER=CR" + N
                    M = M + "SET !PLAYBACKDELAY 0.00" + N
                    M = M + "SET !var1 {{Count}}" + N
                    M = M + "TAB T=1" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[2] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[3] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[4] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[5] EXTRACT=TXT" + N
                    M = M + "ONDOWNLOAD FOLDER=C:\Temp FILE=* WAIT=YES" + N
                    M = M + "WAIT SECONDS=2" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[6]/a" + N
                    M = M + "WAIT SECONDS=5" + N
                    M = M + "SET !TIMEOUT_STEP 60" + N
                Browser = iim1.iimPlayCode(M)
                FileName = iim1.iimGetLastExtract(1)
                FileDate = iim1.iimGetLastExtract(2)
                FileSize = iim1.iimGetLastExtract(3)
                FileIteration= iim1.iimGetLastExtract(4)     


the html for the "download" element is
Code: Select all
<a href="#" class="btn btn-primary" onclick="downloadFile('rebrkso/.history/REBRKSO.RECAIFPL.J2017333.N06019018951513.2017-11-29.0410','REBRKSO','REBRKSO.RECAIFPL.J2017333.N06019018951513');">Download</a>


the full script is
Code: Select all
Option Explicit

Const iM_ElementNotFound        = -1300
Const iM_EndOfFile              = -1240
Const iM_EvalError              = -1340
Const iM_BrowzConnErr           = -1340
Const iM_BadParam               = -1200
Const iM_Success                = 1
Const ForAppending              = 8
Const OpenAsASCII               = 0
Const CreateIfNotExist          = True

Dim Count, Date, Extract, FileName, FileDate, FileSize, FileIteration, i, iMacros, M, objFile, Processed, Skip, FileInfo

Dim WshShell    : Set WshShell  = CreateObject("WScript.Shell")
Dim iim1        : Set iim1      = CreateObject("iMacros")
Dim Browser     : Browser       = iim1.iimOpen("-cr", true)
Dim objFso      : Set objFso    = CreateObject("Scripting.FileSystemObject")
Dim iDayNumber  : iDayNumber    = DateDiff("d", CDate("1/1/" & Year(Now)), Now) + 1
Dim varLMonth   : varLMonth     = Month(Now) - 1
Dim varDateFull : varDateFull   = Month(Now) & "-" & Day(Now) & "-" & Year(Now)
Dim varOldPW    : varOldPW      = "Client" & Year(Now) & varLMonth
Dim Output      : Output        = "C:\temp\Output" & "_" & varDateFull & ".csv"
Dim LogName     : LogName       = "C:\temp\Client1 iMacros Error log" & varDateFull & ".txt"
Dim DateSearch  : DateSearch    = "J" & Year(Now) & iDayNumber
Dim CountString : CountString   = "Default"
Dim Total       : Total         = "Default"
Dim FirstRun    : FirstRun      = "True"
Dim NewMonth    : NewMonth      = "False"
Dim N           : N             = vbNewLine

    If Len(Day(Now))    =   1   Then varDay         = "0" & varDay
    If Len(Month(Now))  =   1   Then varMonth       = "0" & varMonth
    If Day(Now)         =   1   Then FirstOfMonth   = "True"

    If objFSO.FileExists(Output) Then
        Set Output = objFSO.OpenTextFile(Output, ForAppending, OpenAsASCII)
        FirstRun = False
    Else
        Set Output = objFSO.CreateTextFile(Output, ForAppending, OpenAsASCII)
        If Err <> 0 Then
        End If
    End If
        Browser = iim1.iimSet("DateSearch", DateSearch)
        Browser = iim1.iimSet("varOldPW", varOldPW)
       
            M = "CODE:"
            M = "VERSION BUILD=844 RECORDER=CR" + N
            M = M + "TAB T=1" + N
            M = M + "TAB CLOSEALLOTHERS" + N
            M = M + "URL GOTO=https://www.website.com/" + N
            M = M + "TAG SELECTOR=#httpd_username CONTENT=username" + N
            M = M + "TAG SELECTOR=#loginButton" + N
            M = M + "SET !ENCRYPTION NO" + N
                If NewMonth = "False" Then 
                    M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:httpd_password CONTENT=Password{{!NOW:yyyymm}}" + N
                    M = M + "WAIT SECONDS=1" + N
                    M = M + "TAG SELECTOR=#loginButton" + N
                Else
                    M = M + "TAG SELECTOR=#httpd_password CONTENT=password{{varOldPW}}" + N
                    M = M + "ONDIALOG POS=1 BUTTON=OK CONTENT=" + N
                    M = M + "TAG SELECTOR=#httpd_username CONTENT=username" + N
                    M = M + "TAG SELECTOR=#loginButton" + N
                    M = M + "TAG XPATH=""//*[@id='home']/div[3]/div/div/input" + N
                    M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:currentPassword CONTENT={{varOldPw}}" + N
                    M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:newPassword CONTENT={{!NOW:yyyymm}}" + N
                    M = M + "TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:confirmPassword CONTENT={{!NOW:yyyymm}}" + N
                    M = M + "TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:changepassword" + N
                    M = M + "TAG SELECTOR=#serviceList>A>IMG" + N
                    M = M + "URL GOTO=https://website.com/MailBoxWebService/webmailbox/home" + N
                End If
            M = M + "WAIT SECONDS=2" + N
            M = M + "TAG SELECTOR=""#serviceList>A>IMG""" + N
            M = M + "TAG POS=1 TYPE=B ATTR=TXT:Mail<SP>Box" + N
            M = M + "TAG POS=1 TYPE=A ATTR=TXT:Brock<SP>and<SP>Scott<SP>Outbox<SP>(REBRKSO)" + N
            M = M + "SET !TIMEOUT_PAGE 180" + N
            M = M + "SET !TIMEOUT_STEP 100" + N
            M = M + "EVENT TYPE=CLICK SELECTOR=""HTML>BODY>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>FORM>DIV>DIV:nth-of-type(2)>LABEL>INPUT"" BUTTON=0" + N
            M = M + "EVENTS TYPE=KEYPRESS SELECTOR=""HTML>BODY>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>FORM>DIV>DIV:nth-of-type(2)>LABEL>INPUT"" CHARS=""{{DateSearch}}""" + N
            'M = M + "TAG POS=1 TYPE=INPUT:SEARCH FORM=NAME:downloadFiles ATTR=* CONTENT={{DateSearch}}" + N
            M = M + "TAG SELECTOR=#file_details_info EXTRACT=TXT" + N
            M = M + "SET !TIMEOUT_STEP 25" + N
        Browser = iim1.iimPlayCode(M)
        CountString = iim1.iimGetLastExtract(1)
        Total = trim(split(CountString, " ")(5))
            For Count = 1 to Total
                Set M = Nothing
                Skip = False
                Browser = iim1.iimInit("", True, 300)
                Browser = iim1.iimSet("Count", Count)
                WScript.Echo("Beginning Loop for File Info and File Download. Current Loop = " & Count & "Of" & Total)
                    M = "CODE:"
                    M = "VERSION BUILD=844 RECORDER=CR" + N
                    M = M + "SET !PLAYBACKDELAY 0.00" + N
                    M = M + "SET !var1 {{Count}}" + N
                    M = M + "TAB T=1" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[2] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[3] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[4] EXTRACT=TXT" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[5] EXTRACT=TXT" + N
                    M = M + "ONDOWNLOAD FOLDER=C:\Temp FILE=* WAIT=YES" + N
                    M = M + "WAIT SECONDS=2" + N
                    M = M + "TAG XPATH=//*[@id=""file_details""]/tbody/tr[{{COUNT}}]/td[6]/a" + N
                    M = M + "WAIT SECONDS=5" + N
                    M = M + "SET !TIMEOUT_STEP 60" + N
                Browser = iim1.iimPlayCode(M)
                FileName = iim1.iimGetLastExtract(1)
                FileDate = iim1.iimGetLastExtract(2)
                FileSize = iim1.iimGetLastExtract(3)
                FileIteration= iim1.iimGetLastExtract(4)                               
                Wscript.Echo("File Name = " & FileName)
                Wscript.Echo("File Date = " & FileDate)
                Wscript.Echo("File Size = " & FileSize)
                Wscript.Echo("File Iteration = " & FileIteration)
                If objFSO.FileExists(FileName) Then
                    Count = Count + 1
                Else
                    If Browser = iM_Success Then
                        FileInfo = FileName & "," & FileDate & "," & FileSize & "," & FileIteration
                        Count = Count + 1
                        Output.Write(FileInfo) & vbCrLf
                    ElseIf Browser = iM_BadParam Then
                        Count = Count + 1
                        FileInfo = iim1.iimGetLastExtract(1)
                    Else
                    End If
                End If
            Next
        Set M  = Nothing
        Browser = iim1.iimInit("-cr", false, 300)
        Browser = iim1.iimSet("Count", Count)
            M = "CODE:"
            M = "VERSION BUILD=844 RECORDER=CR" + N
            M = M + "TAG POS=1 TYPE=INPUT:SEARCH ATTR=ARIA-CONTROLS:file_details" + N
            M = M + "TAG POS=1 TYPE=H4 ATTR=TXT:Files<SP>Available<SP>for<SP>Download<SP>under<SP>mailbox<SP>REBRKSO" + N
            M = M + "TAG POS=1 TYPE=A ATTR=TXT:Account" + N
            M = M + "TAG POS=1 TYPE=SPAN ATTR=CLASS:glyphicon<SP>glyphicon-log-out" + N
        Browser = iim1.iimPlayCode(M)
    Output.Close                                                        'Close the CSV File
    Browser = iim1.iimExit()                                            'Close the Browser
    WScript.Echo("Data Extracted : " & FileInfo)
    If Count <> Total Then WScript.Echo("Proceeding to next iteration (" & Count & ")")
    If Count = Total Then WScript.Echo("All iterations completed (" & Count & ")" & N & "Closing browser, input file & output file) ")
    If Browser < 0  then                                                'If there is an error, take a screenshot, send email, and stop processing
        Browser = iim1.iimTakeBrowserScreenshot ("./screenshot of Discover Error  "  & Hour(Now)&Minute(Now)&Second(Now) & ".png")
        Output.Close   
        Browser = iim1.iimExit()
        If iscr  < 0 then
                                                                        'Need to Send an Email     
        End If
    End If
    WScript.Echo(vbNewLine & "------------ Processing Complete ------------")
    WScript.Quit()


Thanks for any help!

Hum..., securing your Post before you delete it if you find the/a Solution in the meantime instead of sharing your Solution, like you did with your previous Thread which was quite interesting btw, about the 'XPATH' + 'COUNT' Var...
(I usually stop helping Users who delete their Threads instead of sharing their Solution... There are no "stupid" Qt's, well, there are actually, oops...!, but your Post was of "High Quality", if you ever had a Qt/Pb, chances are some other User(s) will one day have it as well and will be happy to find a Thread with Solution... :idea: )

Hum..., I don't really have a "Solution" for you in this one anyway, as I've never used iMB nor the Scripting Interface, so I never did any "Experimenting" with it..., (and I manage to do all "my" Web-Automation using the Free iMacros for FF Add-on, hum, and in pure '.iim' btw, I don't even use '.js' Scripts...), but there is some "Explanation" somewhere in the Wiki or FAQ (or maybe even on the Forum...), about Limitations that can occur in '-silent' or '-tray' Mode(s) that maybe apply to your "Case"...: ... That Web-Browsers were never developed at the origin to be automated or running silently but that they expect some (Human) User Interaction, especially when interacting with the main Browser Interface + OS, like in a Download/Upload/Print/etc..., and those Functionalities are sometimes difficult to get to work "as expected" when trying to automate the Process...
So this is possibly what is happening in your Case... Hopefully sbd else will have already encountered the Pb and will have a better Insight and some Solution for you... :oops:
- (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: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Download File in -silent mode

by Gutt on Wed Nov 29, 2017 10:08 am

Hi, thanks for the reply -- regarding the last post which was deleted, I had removed it because I didn't actually need a solution - I had a typo with my script which I found when reviewing it again - but i do apologize for that, if its any consolation the above script is for the same project so the solution is contained within it :) Appreciate your time in taking a look
Gutt
 
Posts: 5
Joined: Thu Nov 16, 2017 11:41 am


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 10 guests

-->