+ Reply to Thread
Results 1 to 2 of 2

Getting information from password protected website

Hybrid View

  1. #1
    Registered User
    Join Date
    12-27-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    1

    Question Getting information from password protected website

    Hi guys,

    I'm aware of the fact that there are multiple threads on this subject already, and that there are loads of information but somehow I can't get my VBA code to work. I'm trying to fetch data from a password protected website using VBA. I can login, but somehow I keep getting the log in page HTML into my Excel. Of course I want to load the page after the login, so I can get the password protected data. I can't provide you with a link to the website, since it's only accesible from the company's network server.

    Dim HTMLDoc As HTMLDocument
    Dim MyBrowser As InternetExplorer
    Dim MyHTML_Element As IHTMLElement
    Dim MyURL As String
     Sub Stats()
    
     On Error GoTo Err_Clear
     MyURL = ""
     Set MyBrowser = New InternetExplorer
     MyBrowser.Silent = True
     MyBrowser.navigate MyURL
     MyBrowser.Visible = False
     Do
     Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
     Set HTMLDoc = MyBrowser.document
     HTMLDoc.all.UserName.Value = ""
     HTMLDoc.all.Password.Value = ""
     HTMLDoc.all.RememberMe.Value = "false"
     For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
     If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
     Next
     
    Err_Clear:
     If Err <> 0 Then
     Err.Clear
     Resume Next
     End If
     
     MyBrowser.navigate MyURL
    Set HTMLDoc = MyBrowser.document
    Range("S2!A1").Value = HTMLDoc.body.innerText
    MyBrowser.Quit
    
     End Sub
    I don't get why it keeps showing the log in page data, since I already logged in to the website in the beginning of the macro.

    Thanks in advance! I appreciate your help

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Getting information from password protected website

    What happens if you remove all the error handling?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA macro issues (Extract data from password protected website to excel)
    By aleksa12345 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-21-2018, 10:13 AM
  2. Pulling Data From Password Protected Website Using VBA Macro
    By jdautel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2016, 05:53 PM
  3. Excel 2016 - looking for script to get data from password protected website
    By harris1210 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-25-2016, 01:58 PM
  4. Import data from password protected php website (semicolon separated data)
    By JacobKM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-20-2014, 09:10 AM
  5. How to download data from password protected website?
    By Excellearner2012 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2013, 08:40 PM
  6. Replies: 1
    Last Post: 02-21-2013, 02:48 AM
  7. Importing/Refreshing Data from Password-Protected Website
    By daniel3417 in forum Excel General
    Replies: 5
    Last Post: 06-29-2012, 12:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1