How to extract link href value using vba RRS feed

  • Question

  • I want to extract href link value from a webpage using access vba.Html code is given below.I want to extract following value


    Sample HTML is given below.

    </span></div></div></div></div><div class="a-row a-spacing-base"><div class="a-column a-span12 a-text-center"></div></div><div class="a-row a-spacing-medium"><div id="refinementList" class="a-row a-spacing-none"><div id="ref_401720011" class="a-row a-spacing-none s-see-all-c3-refinement s-see-all-refinement-list"><ul class="s-see-all-indexbar-column">
            <li><span class="a-list-item"><a class="a-link-normal" title="Adventure Northumberland" href="/s/ref=sr_in_-2_p_6_0?fst=as%3Aoff&amp;rh=n%3A318949011%2Cp_6%3AA3P5ROKL5A1OLE%7CA1HZ5FPD8FVC3N&amp;bbn=318949011&amp;ie=UTF8&amp;qid=1455259722&amp;rnid=401720011"><span class="refinementLink">Adventure Northumberland</span><span class="narrowValue"> (22,585)</span></a></span><


    Friday, February 12, 2016 5:46 PM

All replies

  •     Dim strV As String
        Dim i As Long
        Dim j As Long

        strV = "Long string you posted"
        i = InStr(1, strV, "href=")
        j = InStr(1, strV, ";bbn=")
        MsgBox Mid(strV, i + 6, j - i - 6)
    • Marked as answer by tahirsatti123 Thursday, February 18, 2016 12:01 PM
    • Unmarked as answer by tahirsatti123 Thursday, February 18, 2016 12:11 PM
    Wednesday, February 17, 2016 7:54 PM
  • thanks for your response,actually i want to extract href value from from following Webpage


    HTML is in this format

     <div class="a-column a-span3 olpDeliveryColumn">
     <p class="a-spacing-mini olpAvailability">
    <ul class="a-vertical">
            <li class="olpFastTrack"><span class="a-list-item">
                In stock.  
            <li><span class="a-list-item">
                Dispatched from Hong Kong.
                    <a href="/gp/help/customer/display.html/ref=olp_intl_help?ie=UTF8&nodeId=502492">Learn more</a> about international shipping.
                <li><span class="a-list-item">
                    Expedited delivery available.
            <li><span class="a-list-item">
                <a href="/gp/aag/details/ref=olp_merch_ship_1?ie=UTF8&amp;asin=B00IKFN8YM&amp;seller=ABF4V1ARUVKO9&amp;sshmPath=shipping-rates#aag_shipping">International & domestic delivery rates</a>
                     and <a href="/gp/aag/details/ref=olp_merch_return_1?ie=UTF8&amp;asin=B00IKFN8YM&amp;seller=ABF4V1ARUVKO9&amp;sshmPath=returns#aag_returns">return policy</a>.

    I want to extract only below mentioned href value.

    a href="/gp/aag/details/ref=olp_merch_ship_1?ie=UTF8&amp;asin=B00IKFN8YM&amp;seller=ABF4V1ARUVKO9&amp;sshmPath=shipping-rates#aag_shipping"

    Thursday, February 18, 2016 12:08 PM
  • If I was doing this I would use regular expressions.  Here is some info on it.  The regular expression will look like this:

    href="(.*)">International & domestic delivery rates

    If I have time later I may add more detail.

    Thursday, February 18, 2016 3:40 PM
  • Sir..i am using IE navigation for extraction.Is this possible that i will use code just like below mentioned.
    IE.navigate "http://www.amazon.co.uk/gp/offer-listing/B00IKFN8YM/ref=olp_page_2?ie=UTF8&f_new=true"
         Do While IE.ReadyState <> 4 Or _
                  IE.Busy = True
                  On Error Resume Next
                 ' MsgBox (ie.ReadyState)
      'Set html = CreateObject("htmlfile")
        Set html = IE.Document
        Set priceData2 = html.getElementsByClassName("a-column a-span3 olpDeliveryColumn").getElementsByTagName("a")
    For Each Item In priceData2
    Debug.Print Item.innerHTML
    Priceval2 = Item.innerHTML
    MsgBox (Priceval2)
    Next Item
    Please modify above code to have href value..thanks
    Thursday, February 18, 2016 4:02 PM