Automated login and downloading of a file from a website

Joined
Feb 22, 2005
Messages
7
Programming Experience
Beginner
I am trying to creating a windows application that can automatically sign into a website and download a file. I have managed to get it to sign in and reach the file, however a windows pop up box appears asking if you want to open or save the file and then specify a location. How can I automate this part?

Basically I want to schedule this to run each morning and download the file without any manual intervention.

VB.NET:
Expand Collapse Copy
Imports System 
Imports System.Windows.Forms 
Imports System.Security.Permissions 
Imports System.Net 


Public Class Form1 

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
      AddHandler _webBrowser.Navigated, AddressOf Me.LoginWebPageLoaded 
      _webBrowser.Navigate("https://website/") 
   End Sub 

   Private Sub LoginWebPageLoaded(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) 
      RemoveHandler _webBrowser.Navigated, AddressOf Me.LoginWebPageLoaded 
      AddHandler _webBrowser.Navigated, AddressOf Me.HomePageLoaded 
      _webBrowser.Document.GetElementById("username").InnerText = "user1" 
      _webBrowser.Document.GetElementById("password").InnerText = "pass1" 
      _webBrowser.Document.GetElementById("submit:login").InvokeMember("click") 
       End Sub 

   Private Sub HomePageLoaded(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) 
      RemoveHandler _webBrowser.Navigated, AddressOf Me.HomePageLoaded 
      AddHandler _webBrowser.Navigated, AddressOf Me.FileRequestLoaded 
      _webBrowser.Navigate("https://website/Test_20092107.zip") 

        End Sub 

   Private Sub FileRequestLoaded(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) 
      
   End Sub 
End Class
 
Back
Top