Web Scraping Login

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Re: Web Scraping Login Help!!!

Try the following macro...

Code:
Option Explicit

Sub E_Oscar_Login()


    Dim ie As Object
    Dim doc As Object
    
    Const READYSTATE_COMPLETE As Long = 4
    
    Set ie = CreateObject("InternetExplorer.Application")
    
    With ie
        .Visible = True
        .navigate "https://www.e-oscar-web.net/EntryController?trigger=Login"
        Do While .Busy Or .readyState <> READYSTATE_COMPLETE
            DoEvents
        Loop
    End With
    
    Set doc = ie.document
    
    With doc
        .querySelector("#companyId").Value = "12345"
        .querySelector("#userId").Value = "XYZ"
        .querySelector("#password").Value = "123"
    End With
    
    doc.querySelector("[value='Login']").Click
    
    Set ie = Nothing
    Set doc = Nothing
    
End Sub

Hope this helps!
 
Upvote 0
Re: Web Scraping Login Help!!!

Try the following macro...

Code:
Option Explicit

Sub E_Oscar_Login()


    Dim ie As Object
    Dim doc As Object
    
    Const READYSTATE_COMPLETE As Long = 4
    
    Set ie = CreateObject("InternetExplorer.Application")
    
    With ie
        .Visible = True
        .navigate "https://www.e-oscar-web.net/EntryController?trigger=Login"
        Do While .Busy Or .readyState <> READYSTATE_COMPLETE
            DoEvents
        Loop
    End With
    
    Set doc = ie.document
    
    With doc
        .querySelector("#companyId").Value = "12345"
        .querySelector("#userId").Value = "XYZ"
        .querySelector("#password").Value = "123"
    End With
    
    doc.querySelector("[value='Login']").Click
    
    Set ie = Nothing
    Set doc = Nothing
    
End Sub

Hope this helps!

Thank you for the help! I am now stuck trying to click on part of the header. The HTML code is below.

<a class="InactiveTabLink" id="Archiveanch" *******='javascr
ipt:left("", "Archive", "LeftReq", "RefreshView?trigger=Opti
onsPageProcess");return false;' href="#">Archive</a>



Thank you!
 
Last edited:
Upvote 0
Re: Web Scraping Login Help!!!

Sorry, which part of the header are you talking about? There's no HTML code below.
 
Upvote 0
Re: Web Scraping Login Help!!!

Sorry, which part of the header are you talking about? There's no HTML code below.


class="InactiveTabLink" id="Archiveanch" *******='javascr
ipt:left("", "Archive", "LeftReq", "RefreshView?trigger=Opti
onsPageProcess");return false;' href="#">Archive
 
Upvote 0
Re: Web Scraping Login Help!!!

Sorry, for some reason when I used the code tags it took the code as a link. Any help is appreciated! Thank you!
 
Upvote 0
Re: Web Scraping Login Help!!!

In that case, once the login button is clicked, you should wait until the new page loads, then you should assign the new document to the object variable doc, and then you can click on your target element.

Code:
Option Explicit

Sub E_Oscar_Login()


    Dim ie As Object
    Dim doc As Object
    
    Const READYSTATE_COMPLETE As Long = 4
    
    Set ie = CreateObject("InternetExplorer.Application")
    
    With ie
        .Visible = True
        .navigate "https://www.e-oscar-web.net/EntryController?trigger=Login"
        Do While .Busy Or .readyState <> READYSTATE_COMPLETE
            DoEvents
        Loop
    End With
    
    Set doc = ie.document
    
    With doc
        .querySelector("#companyId").Value = "12345"
        .querySelector("#userId").Value = "XYZ"
        .querySelector("#password").Value = "123"
    End With
    
    doc.querySelector("[value='Login']").Click
    
    With ie
        Do While .Busy Or .readyState <> READYSTATE_COMPLETE
            DoEvents
        Loop
    End With
    
    Set doc = ie.document
    
    doc.querySelector("#Archiveanch").Click
    
    Set ie = Nothing
    Set doc = Nothing
    
End Sub
 
Upvote 0
Re: Web Scraping Login Help!!!

Thank you for the response. I am getting Runtime error 424 object required pointing to line "doc.querySelector("#Archiveanch").Click "

Thank you!
 
Upvote 0
Re: Web Scraping Login Help!!!

I understood the id to be Archiveanch. Is this correct? Any spelling mistakes?

If the id is correct, maybe the new page hasn't fully finished loading. Try stepping slowly through the code by pressing F8. Does this help?
 
Upvote 0
Re: Web Scraping Login Help!!!

I understood the id to be Archiveanch. Is this correct? Any spelling mistakes?

If the id is correct, maybe the new page hasn't fully finished loading. Try stepping slowly through the code by pressing F8. Does this help?


I copied and pasted directly from the DOM. I double checked and it is all spelled correctly. I also stepped through the code (using F8) and also added a wait time of 8 seconds to ensure the page was loaded fully. I still received the same 424 error.

Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top