Html'den Excel'e veri çekme - Baskı Önizleme +- AccessTr.neT (https://accesstr.net) +-- Forum: Microsoft Excel (https://accesstr.net/forum-microsoft-excel.html) +--- Forum: Excel Soruları ve Cevapları (https://accesstr.net/forum-excel-sorulari-ve-cevaplari.html) +--- Konu Başlığı: Html'den Excel'e veri çekme (/konu-html-den-excel-e-veri-cekme.html) |
Html'den Excel'e veri çekme - accessman - 11/01/2020 Arkadaşlar internet sayfasından istediğimiz bilgileri Excel sayfasına alabilmek için genel bir program yapmak istiyorum ama burada hangi aynı element başlığına sahip bilgileriden kaçıncı sıradakini alacağımızı nasıl belirtiyoruz mesela aynı bilgi türünden 10 adet var biz üçüncüyü nasıl alacağız Option Explicit Const sSiteName = "https://www.encodedna.com/" Private Sub GetHTMLContents() ' Create Internet Explorer object. Dim IE As Object Set IE = CreateObject("InternetExplorer.Application") IE.Visible = False ' Keep this hidden. IE.Navigate sSiteName ' Wait till IE is fully loaded. While IE.ReadyState <> 4 DoEvents Wend Dim oHDoc As HTMLDocument ' Create document object. Set oHDoc = IE.Document Dim oHEle As HTMLUListElement ' Create Html element (<ul>) object. Set oHEle = oHDoc.getElementById("ulPost") ' Get the element reference using its ID. Dim iCnt As Integer ' Loop through elements inside the <ul> element and find <h2>, which has the texts we want. With oHEle For iCnt = 0 To .getElementsByTagName("h2").Length - 1 Debug.Print .getElementsByTagName("h2").Item(iCnt).getElementsByTagName("a").Item(0).innerHTML Next iCnt End With ' Clean up. IE.Quit Set IE = Nothing Set oHEle = Nothing Set oHDoc = Nothing End Sub Cvp: Extract Or Get Data From Html Element İn Excel Using Vba - accessman - 11/01/2020 Add Microsoft Html Object Library Reference To make the macro work with an external source such as a webpage, we’ll need Microsoft’s Internet Explore (to open the page and will remain hidden). In-addition, to read and extract contents of Html elements, we’ll have to create few objects using a library. Therefore, first add the Microsoft Html Object Library reference to the application. From the top menu of your Vba editor, click Tools -> References…. In the References window, find and select Microsoft Html Object Library and click OK. |