Avko |
05.04.2022 13:43 |
Predmet:VBA scraping
mozda znate kako bi skinuo viceve sa web stranice u excel?
web stranica: https://icentar.ba/icentar/showtopic.php?id=22
PreuzmiIzvorni kôd (Visual Basic):Sub test()
the_start:
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Top = 0
objIE.Left = 0
objIE.Width = 800
objIE.Height = 600
objIE.Visible = False 'We will see the window navigation
On Error Resume Next
objIE.Navigate ("https://icentar.ba/icentar/showtopic.php?id=22")
Do
DoEvents
If Err.Number <> 0 Then
objIE.Quit
Set objIE = Nothing
GoTo the_start:
End If
Loop Until objIE.ReadyState = 4
MsgBox "webpage has loaded"
Dim AllString As String
Set Alllinks = objIE.Document.getElementsByTagName("a")
For Each Hyperlink In Alllinks
If InStr(Hyperlink.innerText, "Haso") > 0 Then
AllString = Hyperlink.innerText
Exit For
End If
Next
MsgBox AllString
End Sub
|