PDA

View Full Version : [SOLVED] VBA to extract data from WebPages



LutonBarry
01-05-2018, 09:57 AM
I understand it is possible to write VBA to extract information from web pages. Never done this before but can anyone recommend a starter book or reference site I can read to understand where to start?

imgaur7
01-05-2018, 10:53 AM
I am new to this but learning
Sharing something to get an idea here
Refer
39490-IE-Automation-using-VBA

Also you may refer some VBA programming books online, else this site members are well knowledgeable in all the way to help you.

LutonBarry
01-08-2018, 08:32 AM
Thanks imgaur7 that's a start and I'll have a read and go from there. think i'll need more help though in the future.

imgaur7
01-09-2018, 04:31 AM
Thanks imgaur7 that's a start and I'll have a read and go from there. think i'll need more help though in the future.

Great and happy to help you in a way....let me know more if required I will share my findings....though waiting for my help ☺

imgaur7
01-09-2018, 10:11 PM
Great and happy to help you in a way....let me know more if required I will share my findings....though waiting for my help ☺



Dim IE as Object
Sub Sprint()
Dim objelement As Object
Dim c As Integer
Dim LastRow, i, j As Integer

Set IE = CreateObject("InternetExplorer.Application")

With IE
.Visible = True
.navigate "https://website url here #"

'wait until first page loads
Ieready
On Error Resume Next

Set sht = ThisWorkbook.Worksheets("Data")
LastRow = sht.Cells(sht.Rows.Count, "B").End(xlUp).Row
For j = 4 To LastRow

i = 112

If IE.document.all.Item(i).innertext = "ФНС (гос. пошлина)" Then
IE.document.all.Item(i).Click

End If

IE.Visible = True

Ieready

'populate fields

With IE.document
'text boxes

.all("fio").Value = sht.Cells(j, 1)
.all("contact").Value = sht.Cells(j, 2)
.all("payer_address").Value = sht.Cells(j, 3)
.all("inn_from").Value = sht.Cells(j, 4) '"771562265931"
.all("inn").Value = sht.Cells(j, 5) '"7726062105"
.all("account").Value = sht.Cells(j, 6) '"45914000"
.all("purpose").Value = sht.Cells(j, 7)
.all("comment").Value = sht.Cells(j, 8) '"02.04.2016"
.all("sum").Value = sht.Cells(j, 10) '"1000"
.all("get_total_sum").Click
'.all("now_pay").Click

End With
Set IE = Nothing

Next j
End With
End Sub
Private Sub Wait(ByVal wSec As Long)
wSec = wSec + Timer
Do While Timer < wSec
DoEvents
Loop
End Sub
Private Sub Ieready()
Wait 5
Do While IE.readyState <> 4
Wait 5
Loop
End Sub