scrapping Data from web

Armaghan12

New Member
Joined
Jul 17, 2018
Messages
3
Hi,
I am newbie please help I need to extract addresses by entering lat and long on below mention website and need to extract data on text box on which it appears.

but it is giving error of object variable or with block variable not set

Please also tell me how get data from text box thanks

Code:
Public Sub newMin()
Dim ie As Object
Dim form As Variant, button As Variant


Dim aLat As String
Dim aLong As String


Set ie = CreateObject("internetexplorer.application")


aLat = "24.323"
aLong = Range("B2")






ie.Visible = True
ie.navigate ("https://www.latlong.net/Show-Latitude-Longitude.html")


While ie.readystate <> 4
DoEvents
Wend


ie.document.getelementsbyname("hU4543").Item.innertext = aLat
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,309
Try identifying the input elements by their placeholder attribute...

Code:
Dim e As Object

For Each e In ie.document.getElementsByTagName("input")
    If e.getAttribute("placeholder") = "lat" Then
        e.innerText = aLat
    ElseIf e.getAttribute("placeholder") = "long" Then
        e.innerText = aLong
    End If
Next e

Hope this helps!
 

Armaghan12

New Member
Joined
Jul 17, 2018
Messages
3
thanks for reply domenic but when i click the button its says fields are required how shall I deal with it



Code:
For Each e In ie.document.getElementsByTagName("input")
    If e.getAttribute("placeholder") = "lat" Then
        e.innerText = aLat
    ElseIf e.getAttribute("placeholder") = "long" Then
        e.innerText = aLong
    End If
Next e


For Each e In ie.document.getElementsByTagName("button")
    If e.getAttribute("title") = "Show Lat Long converted address on Map" Then
        e(0).Click
   
    End If
Next e
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,309
Sorry, unfortunately I don't know why you're getting that message. Hopefully some else here on the Board will be able to help.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,533
Messages
5,529,395
Members
409,870
Latest member
Well59
Top