VBA Wesite Login

PDTAA2017

New Member
Joined
Dec 17, 2019
Messages
4
Office Version
  1. 2013
Platform
  1. Windows
**Definitely a beginner. Please bear with me. First attempt at web scrapping.**

I need the following URL to auto-login and retrieve a table from the website. I have pieced together VBA code from different websites to fill in the login information and hopefully pull a table but I am unable to figure out exactly what the tag/element names are.

I have posted the part of the coding, I have gotten to work from what I watched.

Option Explicit

Sub BrowseToSite()

Dim IE As New SHDocVw.InternetExplorer

IE.Visible = True
IE.navigate "itrac360.com/#/report/5b5628d7a6c91c1b56a0a4b9"

Do While IE.readyState <> READYSTATE_COMPLETE
Loop

Debug.Print IE.LocationName, IE.LocationURL

End Sub

Here is the HTML code from the site:
Username:
<input type="text" class="form-control ng-not-empty ng-dirty ng-valid-parse ng-valid ng-valid-required ng-touched" placeholder="Email" ng-model="loginForm.username" ng-required="true" autofocus="" required="required" aria-invalid="false" style="">


Password:
<input type="password" class="form-control ng-not-empty ng-dirty ng-valid-parse ng-valid ng-valid-required ng-touched" placeholder="Password" ng-model="loginForm.password" ng-required="true" required="required" aria-invalid="false" style="">


Login button:
<input value="Login" class="btn btn-primary form-control" type="submit">

Any assistance would be appreciated (insert begging for help here)
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
VBA Code:
Sub BrowseToSite()
    Dim URL As String
    Dim email As String
    Dim password As String
    
    email = "PDTAA2017@mrexcel.com"
    password = "blablabla"
    URL = "itrac360.com/#/report/5b5628d7a6c91c1b56a0a4b9"
    
    Set IE = CreateObject("internetexplorer.application")
    
    IE.Visible = True
    IE.navigate URL
    
    Do
        DoEvents
    Loop Until IE.readystate = 4
    
    ' Add Email
    IE.document.querySelector("input[placeholder*= Email]").Value = email
    ' Add Password
    IE.document.querySelector("input[placeholder*= Password]").Value = password
    ' Smash that login button
    IE.document.querySelector("input[value*= Login]").Click

End Sub
 
Upvote 0
Thanks! Much better than my attempt.

I just have one more question, once I run the error the login screen stalls. There is a flip card before it goes to the actual dashboard. Is it anyway to bypass this?

Here is the full code:
VBA Code:
<div class="login-form ng-scope">
<div class="icon-container padding-right">
<div>
<span class="icon icon-first"><i class="icon-stratix-doughnut"></i></span>
<span class="icon icon-second"><i class="icon-stratix-bar-chart"></i></span>
<span class="icon icon-third"><i class="icon-stratix-multiseries-column"></i></span>
<span class="icon icon-fourth"><i class="icon-stratix-line"></i></span>
</div>
<div class="left">
<span class="icon icon-inverted icon-first"><i class="icon-stratix-doughnut left"></i></span>
<span class="icon icon-inverted icon-second"><i class="icon-stratix-bar-chart left"></i></span>
<span class="icon icon-inverted icon-third"><i class="icon-stratix-multiseries-column left"></i></span>
<span class="icon icon-inverted icon-fourth"><i class="icon-stratix-line left"></i></span>
</div>
    </div>
    <div flippable="" flipped="loginForm.flipped" class="login-card itrac-flippable ng-isolate-scope"><div class="mask"><div class="card" ng-class="{flipped: flipped}" ng-transclude="">
<div flippable-front="" class="panel panel-success login-pane face front ng-scope ng-isolate-scope">
<div class="panel-heading text-center">
                <h2 class="panel-title">Welcome to</h2>
                <div class="title">itrac360</div>
</div>
<div class="panel-body">
<!-- ngIf: loginForm.$$loading -->
<!-- ngIf: !loginForm.$$loading --><form ng-if="!loginForm.$$loading" class="form-horizontal ng-pristine ng-valid ng-scope ng-valid-required" ng-submit="loginForm.login()">
<div class="input-group" has-errors="">
<span class="input-group-addon"><i class="fa fa-envelope-o"></i></span>
<input type="text" class="form-control ng-pristine ng-valid ng-not-empty ng-valid-required ng-touched" placeholder="Email" ng-model="loginForm.username" ng-required="true" autofocus="" required="required" aria-invalid="false" style="">
</div>
<div class="input-group" has-errors="">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<input type="password" class="form-control ng-pristine ng-untouched ng-valid ng-not-empty ng-valid-required" placeholder="Password" ng-model="loginForm.password" ng-required="true" required="required" aria-invalid="false">
</div>
<div class="text-center"><a ng-click="loginForm.requestPasswordReset()" class="clickable"><i>Forgot
Password?</i></a></div>
<div class="login-submit">
<input value="Login" class="btn btn-primary form-control" type="submit">
</div>
<div class="text-center pull-bottom" style="width: 90%;"><img style="height: 42px;" src="images/itrac360_Logo_Standard_RGB.svg"></div>
</form><!-- end ngIf: !loginForm.$$loading -->
</div>
</div>
<div flippable-back="" class="login-pane face back ng-scope ng-isolate-scope">
<!-- ngInclude: loginForm.backCardHtml --><div ng-include="loginForm.backCardHtml" style="height: 100%;" class="ng-scope"><div class="panel panel-primary ng-scope" style="height: 100%;">
<div class="panel-heading text-center">
        <h2 class="panel-title ng-binding">Good Morning,</h2>
        <div class="title">
<!-- ngIf: loginForm.displayName --><span ng-if="loginForm.displayName" class="ng-binding ng-scope">Jasmine</span><!-- end ngIf: loginForm.displayName --><!-- ngIf: !(loginForm.displayName) -->
</div>
</div>
<div class="panel-body">
<div class="col-md-12">
<time datetime="2014-09-20" class="icon center-block">
<em class="ng-binding">Wednesday</em>
<strong class="ng-binding">December</strong>
<span class="ng-binding">18</span>
</time>
</div>
<div class="col-md-12 vpadding top text-center">
<img src="images/loading-24.gif">
</div>
<div class="col-md-12 greeting-quote pull-down">
<div class="quote text-muted"><i class="ng-binding">Everything has beauty, but not everyone can see.</i></div>
<div class="pull-right ng-binding">- Confucius</div>
</div>
</div>
</div>
</div>
</div>
    </div></div></div>
    <div class="icon-container padding-left">
<div>
<span class="icon icon-fourth"><i class="icon-stratix-multiseries-line"></i></span>
<span class="icon icon-third"><i class="icon-stratix-multiseries-bar"></i></span>
<span class="icon icon-second"><i class="icon-stratix-stacked-area"></i></span>
<span class="icon icon-first"><i class="icon-stratix-stacked-column"></i></span>
</div>
<div class="right">
<span class="icon icon-inverted icon-fourth"><i class="icon-stratix-multiseries-line right"></i></span>
<span class="icon icon-inverted icon-third"><i class="icon-stratix-multiseries-bar right"></i></span>
<span class="icon icon-inverted icon-second"><i class="icon-stratix-stacked-area right"></i></span>
<span class="icon icon-inverted icon-first"><i class="icon-stratix-stacked-column right"></i></span>
</div>
</div>
</div>
 
Last edited by a moderator:
Upvote 0
Not sure I understand what you mean. After you successfully login what do you have to do? Are you clicking anywhere and can you inspect element.
 
Upvote 0
I attached a photo of what is should look like vs. below, this is what I see from the code. Thank you again for your help!

1576697141246.png
 

Attachments

  • IMG_0122.PNG
    IMG_0122.PNG
    196.8 KB · Views: 22
  • IMG_0123.PNG
    IMG_0123.PNG
    203.5 KB · Views: 18
  • IMG_0124.PNG
    IMG_0124.PNG
    203.5 KB · Views: 16
  • IMG_0125.PNG
    IMG_0125.PNG
    180.4 KB · Views: 18
Upvote 0
Code:
What if you just use "https://itrac360.com/"  for the URL?
 
Upvote 0
and it just hangs there? Try commenting out the click submit piece and doing that yourself manually and verifying you are actually using the correct email and password. Im not sure why it would hang. It should be exactly like if you were doing it yourself through the browser manually.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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