Jump to content

Need to save file without direct access to actual file or GUI


Recommended Posts

So I'm currently writing a script to navigate a bunch of webpages to login and download a couple .zip files. It needs to run in Windows Task Scheduler while I am not logged in, so I don't have access to GUI stuff. It runs perfectly fine until it actually has to download the files, because the links you click to download the files aren't the actual files and instead generate or fetch the files from a separate server and download them as the browser would normally.

Trying InetGet() hasn't worked because I'm assuming it needs direct access to the file from the URL provided, which I don't have.

And simply automating a click like with _IEAction() won't work because that would just pull up the IE Download window which I can't access due to no GUI.

I'm also assuming I don't have access to the server where the files are because these files are coming from IBM so they are probably securing it.

The href is just a bunch of properties passed to the site to know what file is needed.

I am at a loss and need some help.

Link to comment
Share on other sites

Unfortunately, there isn't enough information provided to know how to help. Can you tell us more about the website(s) involved? Are they public facing? Can you show us what the link URL looks like? How do they differ from the actual download link (press Ctrl+J to bring up the download window)?

Can you show us the HTML from one of the site's pages, including any Javascript?

Link to comment
Share on other sites

1 hour ago, Danp2 said:

Unfortunately, there isn't enough information provided to know how to help. Can you tell us more about the website(s) involved? Are they public facing? Can you show us what the link URL looks like? How do they differ from the actual download link (press Ctrl+J to bring up the download window)?

Can you show us the HTML from one of the site's pages, including any Javascript?

Sure. The website is definitely not public facing, as the link to get there involves www-01.ibm.com followed by specific paths to get to what I need, and then I have to navigate to the login page and login with our company information to actually get to the download links needed. The link href is something like DownloadCSV.do?regionCode=XXX&fileCntryName=XXX etc. with a bunch of other properties included. The actual download link follows a format of "CountryMonthDayYear.zip". I don't know if I'm allowed to include the HTML unfortunately, but I can post how I find the link and click it:

Local $tags = _IETagNameGetCollection($oIE, "tr")

;search for the download link and click it and wait.
For $tag in $tags
    $textValue = $tag.innerHTML
    If StringInStr($textValue, "Software - United States") > 0 Then
        Local $link = _IETagNameGetCollection($tag, "a", 0)
        _IEAction($link, "click")
        _IELoadWait($oIE)
        If @error = 0 Then
            ExitLoop
        EndIf
   EndIf
Next

The actual link doesn't have an id, name, or unique text I can use so instead I have to look through elements for specific text and then click the link within that element.

Link to comment
Share on other sites

Using AutoIT at IBM?  That's not on their approved list! (kidding)

I suggest my signature when people do loops to find IE elements.  It allows you to do complex searches, and contains all the loops wiithin it, so you only need a single call for each situation.

Yours (guessing) would be like '//tr//*[contains(.,"Software - United States")]//a'

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

IE also has developer tools. I would say that there is a java function attached to the onclick of the download element. You can call it directly and modify it a bit to save the file without asking for save path. Can you post the download button html code?

Link to comment
Share on other sites

Right now I have access to Chrome, as I only use IE on the remote server we're using for this script. But I did find what I think is the HTML code.

<tr>
  <!-- country -->
    <td style="padding-top: 13px">
        Software - United States
        
    </td>
    
  <!-- pricing -->
    <td class="ibm-ind-link">
        <p><a class="ibm-download-link"  href="DownloadCSV.do?*LOTS OF VARIOUS PROPERTIES GO HERE*">SRP/SVP</a></p>
        
    </td>
    
  <!-- date -->
    <td style="padding-top: 13px">
        <p>17 Apr 2018</p>

    </td>
    
  <!-- approximate size -->
    <td style="padding-top: 13px">
        <p>943.64 kb (.zip file) </p>

    </td>
</tr>

I also got some stuff from the Event Listeners for the link.

image.png.96e453d1c080751ba2f2ba5abaa0ee39.png

Link to comment
Share on other sites

Yep I found the click event and can copy and paste it, and it's all minimized onto one line that stretches across several pages if I were to paste it here. It also has this attached:

// Licensed Materials - Property of IBM, eluminate.js (US Build # 4.21.99 Date/Time: 20180321-14:32), (C) Copyright IBM Corporation 2018. U.S. Government Users Restricted Rights:  Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

 

Link to comment
Share on other sites

Alright, just wanted to make sure lol. Don't want to share stuff I'm not allowed to share, and I don't know where that line is so I tend to err on the side of caution.

But yeah that's what the onclick event is for the link.

Link to comment
Share on other sites

function cW(b, a) {
    CI();
    var b = CG(b);
    if (b) {
        C9(b, a)
    }
    CJ(1);
    CE();
    if (a) {
        setTimeout(a, cm_LinkClickDelayInterval)
    } else {
        if (cm_LinkClickDelay) {
            if (b) {
                setTimeout('document.location = "' + b.href + '"', cm_LinkClickDelayInterval);
                return false
            } else {
                return true
            }
        }
    }
}

I got this by pretty-printing the file and looking back at the event for the link.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...