Prikazi cijelu temu 05.04.2022 13:43
Avko Van mreze
Administrator
Registrovan od:28.05.2014
Lokacija:zagreb


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):
  1. Sub test()
  2.    
  3. the_start:
  4.    
  5.     Set objIE = CreateObject("InternetExplorer.Application")
  6.     objIE.Top = 0
  7.     objIE.Left = 0
  8.     objIE.Width = 800
  9.     objIE.Height = 600
  10.     objIE.Visible = False 'We will see the window navigation
  11.    
  12.     On Error Resume Next
  13.     objIE.Navigate ("https://icentar.ba/icentar/showtopic.php?id=22")
  14.    
  15.     Do
  16.     DoEvents
  17.         If Err.Number <> 0 Then
  18.             objIE.Quit
  19.             Set objIE = Nothing
  20.             GoTo the_start:
  21.         End If
  22.     Loop Until objIE.ReadyState = 4
  23.    
  24.     MsgBox "webpage has loaded"
  25.    
  26.     Dim AllString As String
  27.    
  28.     Set Alllinks = objIE.Document.getElementsByTagName("a")
  29.     For Each Hyperlink In Alllinks
  30.         If InStr(Hyperlink.innerText, "Haso") > 0 Then
  31.             AllString = Hyperlink.innerText
  32.             Exit For
  33.         End If
  34.     Next
  35.    
  36.     MsgBox AllString
  37.    
  38. End Sub

zivot je moja domovina.