Website Scrapping Question - VBA

Engineer123456

New Member
Joined
Dec 20, 2019
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to write a VBA code to get some info from a website to bring into excel. I am able to go to the website, click the login button, enter by login information, click the sign in button, but then I am stuck trying to close the 'Welcome Popup" on the main page. I should be able to close this welcome popup by writing code to either click the "continue" button or the "exit" button on the welcome popup. The Java code for each of these buttons will be posted below my VBA code. See my VBA code below:

Note: I am currently not getting any errors in excel from running this code, but it will not close the welcome popup.

Sub ASCElogin()

Dim objIE As Object
Dim UserName As String
Dim Password As String
UserName = Range("G7").Value
Password = Range("G8").Value

'Open Internet Explorer
Set objIE = CreateObject("InternetExplorer.Application")

With objIE
.AddressBar = False
.StatusBar = False
.MenuBar = False
.Toolbar = 0
.Visible = True
.navigate "ASCE 7 Hazard Tool"

Do Until Not objIE.Busy And objIE.readyState = 4
DoEvents
Loop

End With

'Clicking Login Button then goes to 'sign in' page
For Each HTMLInputElement In objIE.document.getElementsByClassName("waves-effect waves-light btn blue darken-3")
If HTMLInputElement.className = "waves-effect waves-light btn blue darken-3" Then
HTMLInputElement.Click

Exit For

End If

Next HTMLInputElement

Do Until Not objIE.Busy And objIE.readyState = 4
DoEvents
Loop

'Entering UserName
For Each HTMLInputElement In objIE.document.getElementsByName("ctl00$main$LoginTextBox")
If HTMLInputElement.Name = "ctl00$main$LoginTextBox" Then
HTMLInputElement.Value = UserName

Exit For

End If

Next HTMLInputElement

'Entering Password
For Each HTMLInputElement In objIE.document.getElementsByName("ctl00$main$PasswordTextBox")
If HTMLInputElement.Name = "ctl00$main$PasswordTextBox" Then
HTMLInputElement.Value = Password

Exit For

End If

Next HTMLInputElement

'Clicking Sign-In button and go to main page
For Each HTMLInputElement In objIE.document.getElementsByName("ctl00$main$SubmitButton")
If HTMLInputElement.Name = "ctl00$main$SubmitButton" Then
HTMLInputElement.Click

Exit For

End If

Next HTMLInputElement

Do Until Not objIE.Busy And objIE.readyState = 4
DoEvents
Loop

'Closing Welcome Popup - this currently does not close the welcome popup - but I do not get any errors

For Each HTMLInputElement In objIE.document.getElementsByClassName("details-popup-close-icon")
If HTMLInputElement.className = "details-popup-close-icon" Then
HTMLInputElement.Click

Exit For

End If

Next HTMLInputElement

End Sub

Java Code:

For the "Continue" button. Continue button is the last line of code below:
<div class="flex flex-column flex-justify-center align-items-center margin-vertical" data-reactid=".0.1.0.4.0.1.1">
<a class="waves-effect waves-light btn blue darken-3" data-reactid=".0.1.0.4.0.1.1.0">Continue</a>

For the exit button in top right corner of the welcome popup. Exit button is last line of code below:
<div class="popup-header blue darken-3 welcome-header" data-reactid=".0.1.0.4.0.0">
<span data-reactid=".0.1.0.4.0.0.0">ASCE 7 Hazard Tool</span>
<span class="details-popup-close-icon" data-reactid=".0.1.0.4.0.0.1"></span>

Any help would be greatly appreciated!

Thanks,
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Is it possible to just navigate to wherever you are wanting to scrape from right after you login? Otherwise you are going to have to figure out how to get the proper parent element. If you inspect element you can see it's not the same as were you are logging in.
 
Upvote 0
Is it possible to just navigate to wherever you are wanting to scrape from right after you login? Otherwise you are going to have to figure out how to get the proper parent element. If you inspect element you can see it's not the same as were you are logging in.
No, unfortunately I need to close that welcome popup, then enter in information before I scrap the info I need. It seems I cannot find the correct parent element. Would It help if I posted more of the Java code to see if you could identify the correct parent element responsible for closing the welcome popup?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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