Download file from a secured link

Hi
I am just looking for a script from which i can download the file from a secured website by putting user name password and then select the link.

Thanks

surah79Asked:
Who is Participating?
 
sungenwangCommented:
Here's a sample code.
sew

strURL = "www.gmail.com"
strUserID = "user_id"
strUserPassword = "user_password"


Set objIE = Createobject("InternetExplorer.Application")

objIE.Visible = True
objIE.Navigate2(strURL)

Call WaitWhileBusy(objIE, 3000, 100)
Call WaitForDocState(objIE, 4, 3000, 100)

objIE.document.getElementsByName("Email")(0).Value = strUserID
objIE.document.getElementsByName("Passwd")(0).Value = strUserPassword

' click on submit button
objIE.document.getElementsByName("signIn")(0).Click




Function WaitWhileBusy(objIE, intTimeout, intWaitInterval) 
	Dim boolResult : boolResult = True
	Dim intSecElapsed : intSecElapsed = 0

	Do
		If intWaitInterval > 0 Then
			WScript.Sleep intWaitInterval

			If intTimeout > 0 Then
				If intSecElapsed > intTimeout Then
					boolResult = False
					Exit Do
				Else
					intSecElapsed = intSecElapsed + intWaitInterval
				End If
			End If
		End If
	Loop While objIE.busy

	WaitWhileBusy = boolResult
End Function

Function WaitForDocState(obj, intState, uSecTimeOut, intWaitInterval)
	Dim boolResult : boolResult = True
	Dim intSecElapsed : intSecElapsed = 0

	Do
		If intWaitInterval > 0 Then
			WScript.Sleep intWaitInterval

			If uSecTimeOut > 0 Then
				If intSecElapsed > uSecTimeOut Then
					boolResult = False
					Exit Do
				Else
					intSecElapsed = intSecElapsed + intWaitInterval
				End If
			End If
		End If
	Loop Until intState <= GetDocState(obj)

	WaitForDocState = boolResult
End Function

Function GetDocState(obj)
	On Error Resume Next

	Select Case obj.Document.readyState
		Case "uninitialized"	GetDocState = 0
		Case "loading"		GetDocState = 1
		Case "loaded"		GetDocState = 2
		Case "interactive"	GetDocState = 3
		Case "complete"		GetDocState = 4
		Case Else		GetDocState = -1
	End Select

	On Error Goto 0
End Function

Open in new window

0
 
surah79Author Commented:
thanks a lot for your help
0
 
sungenwangCommented:
you're welcome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.