Jump to content

Background download using IE [Solved]


Recommended Posts

!!!solution at the bottom of this post!!!

I recently started writing a small bank account diagnostic tool that gets it data from files downloaded from my online banking account.

I've succeeded in logging in and navigating to the download page. (troublesome as all the pages and links are created dynamically).

After that I managed to specify the properties for the file and simulate a mouse click to start the download.

So far I was able to do everything in a hidden Internet explorer window, but the "download dialogue", "save file dialogue" and "download finished dialogue" are all created as visible.

I've automated them as well, but the windows flashing through the screen are an eyesore.

To minimize the time the windows are visible I'm currently using:

$hwnd = WinWait("[TITLE:Bestand downloaden; CLASS:#32770]", "mijn.ing.nl", 5000)
WinSetState($hwnd, "", @SW_HIDE)

But I was hoping to stop the window from popping up all together. If it helps. The files are just plain csv textfiles, so if I could get internet explorer to open it instead of downloading it I could read the source.

Any ideas on how I could make the download completely invisible would be appreciated.

Tom

PS:

As the script is catered to my banks website (ing.nl) I didn't think posting it would be useful, but if needed I can put together an example script.

[solution]

I could not use inetget() because that returned a "redirect to login" page. The problem was that I was logged in in IE, but _INetGetSource() would start a new session.

By using _IECreateEmbedded() instead of _IECreate(), _INetGetSource() was seen as the same session rather then a new one.... I think.

[/solution]

Edited by Tvern
Link to comment
Share on other sites

_INetGetSource() ?

I guess you'd use that to get the download url?

The download link refers to "#" and has a onclick = doOK(). The download link is generated when I click it.

Here is an example of the download page if that helps.

<html>
<head><title>Downloaden rekeningoverzicht</title>
<link href="css/mpb.css?ing" rel="stylesheet" type="text/css">
<script language="Javascript" type="text/javascript" src="js/mpb.js?ing"></script>
<script type="text/javascript" language="javascript">
function showHelpWindow() {
    
win = window.open("https://mijn.ing.nl/svc/help/HelpServlet?appl=14&onderwerp=SELDOWNLPER", "helpwindow", "menubar=no,resizable=yes,titlebar=yes,scrollbars=yes,top=30,left=30,height=430,width=700,toolbar=no,location=no");
        win.focus();
        
}
</script>
<!-- MF="14,5" -->

</head>
<body >

<table cellpadding="0" cellspacing="0" border="0" width="100%" height="98%">

    <colgroup>
        <col width="100%"></col>
        <col width="10px"/></col>

        <col width="125px"/></col>
    </colgroup>
    
    <tbody>

        <tr valign="top">
            <td width="100%">

    
<script language="Javascript" type="text/javascript">
<!--
function doOk() 
{
    document.form1.action="downloadcheck.do";
    document.form1.submit();
}
function doAnnuleren() {
    document.form1.action = "girorekeningraadplegen.do?seqts=1267741248888&amp;datumtot=04-03-2010";
    document.form1.submit();
}

function downloadFormaatChanged()
{
    document.form1.action = "downloadperiodeselecteren.do";
    document.form1.submit();
}
//-->
</script>

<form onsubmit= "Javascript:predoOk(); return false;" method="post" action="#" name="form1"><div><img src="gfx/dummy.gif" class="formulier-top" border="0" alt=""></div>

<input type="hidden" name="screen" value="downloadperiodeselecteren.do">
<input type="hidden" name="returnscreen" value="girorekeningraadplegen.do?seqts=1267741248888&amp;datumtot=04-03-2010">
<input type="hidden" name="time" value="1">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td class="scherm-titel">Downloaden rekeningoverzicht</td>
        <td align="right"><table cellspacing="0" cellpadding="0" border="0"><tr><td width="6"><a class="help-link" onclick="javascript:showHelpWindow(); return false;" style="cursor: pointer; cursor:hand"><img class="help-link" src="gfx/ing_arrow_right.gif" border="0" alt=""></a></td><td class="help-link-witruimte"><img src="gfx/dummy.gif" alt="" class="help-link-witruimte" border="0"></td><td align="right" width="25"><a class="help-link" href="#" onclick="javascript:showHelpWindow(); return false;">Help</a></td></tr></table></td>
    </tr>
</table>

<div>
    <img src="gfx/dummy.gif" height="10" width="10" alt="">
</div>

        <span class="info-tekst">
            Uw vorige verzoek tot downloaden vond plaats op 04-03-2010 en bevatte de gegevens van 01-03-2010 tot en met 02-03-2010.
        <div><img src="gfx/dummy.gif" height="10" border="0" alt=""></div></span>


<table cellspacing="0" cellpadding="0" border="0" class="formulier" width="100%"> 
<tr><td class="formulier-kop" nowrap align="center" width="10px"><img src="gfx/dummy.gif" width="10px" height="14px" alt=""></td><td width="100%" colspan="3" class="formulier-kop" nowrap>Selecteren periode af- en bijschrijvingen voor het downloaden</td></tr>

<tr><td width="10px" align="center" class="formulier-label"><img src="gfx/dummy.gif" width="7px" height="7px" alt=""></td>
    <td class="formulier-label" width="25%" nowrap>Rekening&nbsp;</td><td class="formulier-label" width="1%"><img src="gfx/dummy.gif" width="10px" height="10px" alt=""></td>
    <td class="formulier-uitvoer"align="left" >
        <select name="rekeningselectie" id="rekeningselectie" class="formulier-select">
            
            
                <option value="-1">Alle rekeningen</option>
            
        <option value="0" selected>xxxxxxx- John Doe</option><option value="1">yyyyyyyyy - somename</option><option value="2">some account - myname</option></select>

    </td>
</tr><tr><td colspan="4" height="1" class="formulier-lijn"></td></tr>

<tr><td width="10px" align="center" class="formulier-label"><img src="gfx/dummy.gif" width="7px" height="7px" alt=""></td>
    <td class="formulier-label" width="25%" nowrap>Van datum *&nbsp;</td><td class="formulier-label" width="1%"><img src="gfx/dummy.gif" width="10px" height="10px" alt=""></td>
    <td class="formulier-invoer">
        <input type="text" class="formulier-text" name="datumvan" id="datumvan" maxlength="10" style="width: 80px;" value="03-03-2010">&nbsp;
    </td>
</tr><tr><td colspan="4" height="1" class="formulier-lijn"></td></tr>

<tr><td width="10px" align="center" class="formulier-label"><img src="gfx/dummy.gif" width="7px" height="7px" alt=""></td>

    <td class="formulier-label" width="25%" nowrap>T/m datum *&nbsp;</td><td class="formulier-label" width="1%"><img src="gfx/dummy.gif" width="10px" height="10px" alt=""></td>
    <td class="formulier-invoer">
        <input type="text" class="formulier-text" name="datumtot" id="datumtot" maxlength="10" style="width: 80px;" value="03-03-2010">&nbsp;
    </td>
</tr><tr><td colspan="4" height="1" class="formulier-lijn"></td></tr>

<tr><td width="10px" align="center" class="formulier-label"><img src="gfx/dummy.gif" width="7px" height="7px" alt=""></td>
    <td class="formulier-label" width="25%" nowrap>Formaat&nbsp;</td><td class="formulier-label" width="1%"><img src="gfx/dummy.gif" width="10px" height="10px" alt=""></td>
    <td class="formulier-invoer">

        <select name="formaat" id="formaat" class="formulier-select" onchange="downloadFormaatChanged()"><option value="kommacsv" selected>Kommagescheiden (jjjjmmdd)</option><option value="kommatxt">Tekst</option><option value="kommaoud">Kommagescheiden (dd-mm-jjjj)</option><option value="asciigto">ASCII - Girotel</option><option value="kommagto">Kommagescheiden - Girotel</option></select>
    </td>
</tr><tr><td colspan="4" height="1" class="formulier-lijn"></td></tr>


<tr><td colspan="4"><img src="gfx/dummy.gif" height="5" width="5" alt=""></td></tr><tr><td colspan="4" class="formulier-voet">* Verplicht veld</td></tr>

</table>

<div><img src='gfx/dummy.gif' height=10 alt=""></div><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>
    <td><a href="#" class="knop-normaal" onclick="doOk(); return false;;return false;"><table border="0" cellspacing="0" cellpadding="0" height="20" bgcolor="#FF6600"><tr class="knop-normaal"><td class="knop-normaal" nowrap>&nbsp;Downloaden&nbsp;</td><td class="knop-normaal" height="17" width="10"></td><td rowspan="2" width="5" height="20"><img src="gfx/gto_button_right.gif?ing" width="5" height="20" alt="" border="0"></td></tr><tr class="knop-normaal"><td background="gfx/gto_button_bottom.gif?ing" height="3" colspan="2"><img src="gfx/dummy.gif" width="1" height="1" alt="" border="0"></td></tr></table></a></td><td><img src="gfx/dummy.gif" width="5" height="1" alt="" border="0"></td>
    <td><a href="#" class="knop-normaal" onclick="doAnnuleren(); return false;;return false;"><table border="0" cellspacing="0" cellpadding="0" height="20" bgcolor="#FF6600"><tr class="knop-normaal"><td class="knop-normaal" nowrap>&nbsp;Terug&nbsp;</td><td class="knop-normaal" height="17" width="0"><img src="gfx/dummy.gif" width="1" height="17" alt="" border="0"></td><td rowspan="2" width="5" height="20"><img src="gfx/gto_button_right.gif?ing" width="5" height="20" alt="" border="0"></td></tr><tr class="knop-normaal"><td background="gfx/gto_button_bottom.gif?ing" height="3" colspan="2"><img src="gfx/dummy.gif" width="1" height="1" alt="" border="0"></td></tr></table></a></td><td><img src="gfx/dummy.gif" width="5" height="1" alt="" border="0"></td>
<td width="100%">&nbsp;</td></tr></table>

<input type="submit" style="margin-left: -3000px;" taborder="2000" tabindex="2000"></form><script language="Javascript" type="text/javascript">
function predoOk() {doOk(); return false;}</script><script type="text/javascript" language="Javascript">document.getElementById('datumvan').focus();</script>

            </td>
            <td align="left" width="10px">

                <img src="gfx/dummy.gif" width="10px" border="0" alt="">
            </td>
            <td valign="top" width="125px">
                <script language="Javascript" type="text/javascript" src="js/service.js"></script><div><img src="gfx/dummy.gif" class="serviceMenuTop" border="0" alt=""></div><table width="120" border="0" cellpadding="1" cellspacing="0"><tr><td>&nbsp;</td></tr></table>
            </td>
        </tr>
        <tr valign="top">
            <td colspan="3" align="right" valign="top">

                <img src="gfx/dummy.gif" width="1" height="55" border="0" alt="">
            </td>
        </tr>
        
    </tbody>
            
</table>

</body>
</html>
Link to comment
Share on other sites

When I have used it, it downloads the whole sourcecode of the page you point it to, which you can then read and manipulate however you choose.

It does, but I'm still clueless as to how that will help me avoid the download prompt.

The problem is that I think the file and the link to it are only generated when I press the download link.

...

While writing this I thought I'd double check that statement and it seems entering an url in the following syntax actually does allow me to download a file that seems to work.

$sesionID = 1267778733894 ;example sesion ID
$datefrom = "03-01-2010" ;dd-mm-jjjj
$dateto = "04-03-2010" ;dd-mm-jjjj
$datatype = "kommacsv"
$downloadall = "true"


$url = "https://mijn.ing.nl/mpb/girordpl/download.do?seqts=" & $sesionID & "&datumvan=" & $datefrom & "&datumtot=" & $dateto & "&formaat=" & $datatype & "&downloadall=" & $DownloadAll

edit:

While the direct link has greatly simplified my script. (no messing around with finding elements in forms in frames) I'm still getting the download prompt. Attempting to use InetGet(), _INetGetSource() and InetRead() all resulted in downloading a page that redirects to the login page. Still looking for a workaround.

Edited by Tvern
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...