extract URL from html using VBA



  • Hi...i wanted to extract the URL from the following piece of html code and paste it in excel sheet.

    <div class="TbwUpd">
    <cite class="iUh30 bc">https://www.extremetech.com › Computing</cite></div>

    this is the code that i tried but it didnt work..can somebody pls help me with this??

    Dim http As Object, html As New HTMLDocument, a As Object, titleElem As Object, detailsElem As Object, b As HTMLHtmlElement
    Dim i As Integer
    Set http = CreateObject("MSXML2.XMLHTTP")
    http.Open "GET", "https://news.ycombinator.com/", False
    http.send
    html.body.innerHTML = http.responseText
    Set a = html.getElementsByClassName("Tbwupd")
    i = 2
    For Each b In a
    Set titleElem = b.getElementsByTagName("Cite")
    Sheets(1).Cells(i, 1).Value = b.getElementsByTagName("iUH30")
    i = i + 1
    Next


  • administrators

    @dhilsha-s There's already an example here - Parse URLs in VBA


Log in to reply
 

Looks like your connection to Codingislove Forum was lost, please wait while we try to reconnect.