Forum

Error scraping web ...
 
Notifications
Clear all

Error scraping web data. Help with the VBA code

2 Posts
2 Users
0 Reactions
85 Views
(@peterstrikes)
Posts: 1
New Member
Topic starter
 

Hello Friends,

 

I am trying to automate using Excel Macro. Here is the breakup of objective-

a. Launch web page -  trweb.co.clark.nv.us

b. Populate web search form with data in column A

c. Click the submit button

d. Store required portion (CellData) of table data in column G

e. Loop to automate.

HERE IS MY CODE. I AM STUCK WITH STEP d.  The required output data has class=CellData and has multiple instances of this class. I tried capturing by tr tag as well but to no avail.  Looping hasn't been done in code yet as I haven't got positive response with Step d.  PLEASE HELP GUYS....

 

Sub PullSitus()

Dim IE As New InternetExplorer
Dim result As MSHTML.HTMLDocument
Dim doc As HTMLDocument

IE.Visible = True
IE.navigate "http://trweb.co.clark.nv.us/"

Do While IE.readyState <> READYSTATE_COMPLETE
Loop

IE.document.forms("Search").elements("Valid_ID").Value = ThisWorkbook.Sheets("Sheet1").Range("A" & 2).Value

'change value propety of "Valid_ID" element of "Search" form with data from cell $A2 of this workbook

IE.document.forms("Search").elements("Submit").Click

'Click on "Submit" element of "Search" form

Do While IE.readyState <> READYSTATE_COMPLETE
Loop

Set doc = IE.document

Set result = doc.getElementsByClassName("CellData").Item(4).innerText
ThisWorkbook.Sheets("Sheet1").Range("G" & 2) = result.Value

End Sub

 
Posted : 16/02/2019 4:42 pm
Philip Treacy
(@philipt)
Posts: 1631
Member Admin
 

Hi Peter,

Can you please supply the workbook with the data to be used in Step b, otherwise the form submission doesn't work.

Please explain what it is you are trying to do and what data you are trying to get from the site, it's hard to work out just by reading code.

Regards

Phil

 
Posted : 16/02/2019 6:53 pm
Share: