Redd500 Posted April 19, 2018 Share Posted April 19, 2018 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 More sharing options...
Danp2 Posted April 19, 2018 Share Posted April 19, 2018 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? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Redd500 Posted April 20, 2018 Author Share Posted April 20, 2018 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 More sharing options...
jdelaney Posted April 20, 2018 Share Posted April 20, 2018 (edited) 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 April 20, 2018 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 More sharing options...
Danp2 Posted April 20, 2018 Share Posted April 20, 2018 Are there events attached to the links? Easiest way to tell is to use the Developer Tools in Firefox. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Juvigy Posted April 20, 2018 Share Posted April 20, 2018 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 More sharing options...
Redd500 Posted April 20, 2018 Author Share Posted April 20, 2018 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. Link to comment Share on other sites More sharing options...
Danp2 Posted April 20, 2018 Share Posted April 20, 2018 (edited) 4 hours ago, Juvigy said: IE also has developer tools. Yes, I know. However, I avoid them because they don't work as well IMO and I find it easier to view the events in FF. Edit: Here's an example -- Edited April 20, 2018 by Danp2 add image Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Redd500 Posted April 20, 2018 Author Share Posted April 20, 2018 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 More sharing options...
Danp2 Posted April 20, 2018 Share Posted April 20, 2018 That file is freely accessing at http://libs.de.coremetrics.com/eluminate.js Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Redd500 Posted April 20, 2018 Author Share Posted April 20, 2018 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 More sharing options...
Danp2 Posted April 20, 2018 Share Posted April 20, 2018 Can you show us the actual onClick code (not the eluminate.js library)? I'm trying to see if it's where we need to focus or if we need more details on the DownloadCSV.do href. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Redd500 Posted April 20, 2018 Author Share Posted April 20, 2018 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 More sharing options...
Danp2 Posted April 20, 2018 Share Posted April 20, 2018 Since we don't have access to the site, you'll need to do some debugging on your end to follow the code and figure out what values are being passed to the cW function and if calling it directly works to download the file. If not, then you probably need to investigate DownloadCSV.do as mentioned above. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Redd500 Posted April 20, 2018 Author Share Posted April 20, 2018 What's being passed to the cW function is the MouseEvent for the <a> element I clicked on and undefined. I don't think I can replicate that by calling it directly unfortunately. Link to comment Share on other sites More sharing options...
Danp2 Posted April 20, 2018 Share Posted April 20, 2018 I know that I've done this previously using Firefox, so it should be possible with IE. Perhaps the jQuerify function will help here -- Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Redd500 Posted April 20, 2018 Author Share Posted April 20, 2018 I guess with Jquery I can just use the href and then catch the file myself? Then I can actually use InetGet()? Link to comment Share on other sites More sharing options...
Danp2 Posted April 20, 2018 Share Posted April 20, 2018 Only one way to find out... Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Dent Posted April 25, 2018 Share Posted April 25, 2018 Did it work? I'm having this exact same issue Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now