Sign in to follow this  
Followers 0
departmentg33k

_IECreate to Log in, INetGet to download

3 posts in this topic

First off, this post does discuss the use of _IECreate to establish a session on a password-protected site. I think my post and the related script is within forum rules, but if mods disagree and it's considered an "Auto-Login Method" as referenced in forum rules mea cupla, please feel free to edit/delete this post.

I'm using _IECreate to log into a "Secure File Transfer" site (https). With the _IECreate session still open, I'm trying to use INetGet to actually download a file, but each time INetGet fails. I can use the same URL I pass to INetGet in the actual, visible browser session, via the address bar, and the requested file loads just fine.

Am I missing something, or does INetGet create it's own session, and not use the authenticated session created with _IECreate?

Sample Code:

#Include <IE.au3>
$Username = "xxxxxxxxxx"
; Debug Mode: 0 = End-User, 1 = Logging----------------------------------------
$DEBUGMODE = 1
;Registers 'ESC' as a Panic Abort Key, if in debug mode------------------------
If $DEBUGMODE = 1 Then
HotKeySet("{ESC}", "_Terminate")
EndIf

;Launches an instance of IE (note, set last param from 1 to 0 to hide window)--
$oIE = _IECreate("https://example.com/~",0,1)
;Perform Automated Login-------------------------------------------------------
$oForm = _IEFormGetCollection($oIE, 0)
$oField_User = _IEFormElementGetObjByName($oForm, 1)
$oField_Pass = _IEFormElementGetObjByName($oForm, 2)
$oBut_Submit = _IEFormElementGetObjByName($oForm, 3)
$enter_user = _IEFormElementSetValue($oField_User, $Username)
$enter_pass = _IEFormElementSetValue($oField_Pass, "*******")
$click_subm = _IEAction($oBut_Submit, "click")
Sleep(1000)
$CurrentPage = _IENavigate($oIE, "https://example.com/download")
;------------------------------------------------------------------------------

$oLinks = _IELinkGetCollection ($oIE)
$savedir = "C:\ScriptTemp\cache"
For $oLink In $oLinks
    If StringInstr($oLink.href,".txt?P") Then
        _InetGet($oLink.href,$savedir & "\" & StringLeft(StringRight($oLink.href,20),18), 27)&@CRLF)
    EndIf
Next

I have verified the $oLinks collection contains valid links using ConsoleWrite, and I can manually download using these links.

Thanks in advance, I'm long-time reader, first-time poster.

Share this post


Link to post
Share on other sites



It creates its own unique connection unrelated to your browser session.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

It creates its own unique connection unrelated to your browser session.

Dale

Thanks for the rapid response Dale!

So am I correct in my understanding that INetGet cannot be made to use the same session as created by _IECreate? I had a semi-working version using _IENavigate, I just didn't like having to mess with the file>save dialog, I was trying to use IE in hidden mode, as this is a script to automate a process for a "less than technical" user.

Thanks!

Share this post


Link to post
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
Sign in to follow this  
Followers 0