Predmet:skidanje html table u excel
htio bi skinuti html tablu sa web stranice. Ovaj kod radi kada ide samo jednom, no kada zelim dodati drugi link i nastaviti skidati table onda stane
radi se o spisku pjesama sa web stranice regionalnog radija
evo i kod ako netko ne zeli skidati excel datoteku ili ako netko vizuelno moze da rijesi problem:
PreuzmiIzvorni kôd (Text):Sub HTML_Table_To_Excel()
Dim htm As Object
Dim tr As Object
Dim td As Object
Dim Tab1 As Object
Column_Num_To_Start = 1
iRow = 2
iCol = Column_Num_To_Start
iTable = 0
'1-31
For dan = 1 To 31 'bez ovoga radi
'Replace the URL of the webpage that you want to download
'Web_URL = "https://radio.hrt.hr/drugi-program/sto-svira/2020/1/8/"
Web_URL = "https://radio.hrt.hr/drugi-program/sto-svira/2020/1/" & dan & "/"
'Create HTMLFile Object
Set HTML_Content = CreateObject("htmlfile")
'Get the WebPage Content to HTMLFile Object
With CreateObject("msxml2.xmlhttp")
.Open "GET", Web_URL, False
.send
HTML_Content.body.innerHTML = .responseText 'this is the highlighted part for the error
End With
'Loop Through Each Table and Download it to Excel in Proper Format
For Each Tab1 In HTML_Content.GetElementsByTagName("table")
With HTML_Content.GetElementsByTagName("table")(iTable)
For Each tr In .Rows
For Each td In tr.Cells
Sheets(1).Cells(iRow, iCol).Select
Sheets(1).Cells(iRow, iCol) = td.innertext
iCol = iCol + 1
Next td
iCol = Column_Num_To_Start
iRow = iRow + 1
Next tr
End With
iTable = iTable + 1
iCol = Column_Num_To_Start
iRow = iRow + 1
Next Tab1
Set htm = Nothing
Set tr = Nothing
Set td = Nothing
Set Tab1 = Nothing
Next dan 'izbrisati ako ne zelimo petlju
MsgBox "gotovo"
End Sub
Prilozi:
skidanje liste sta je sviralo.zip
Preuzimanja:285
Velicina datoteke:14.50 KB
zivot je moja domovina.