title: Getting Links/URL from a webpage-Excel VBA
body: <p><img src="https://i.stack.imgur.com/XYrEx.jpg" alt="enter image description here"></p>
  
  <p>I want to write a macro which will take the search result links in a webpage. I have written like this</p>
  
  <pre><code>Sub webpage()
  
  Dim internet As InternetExplorer
  
  Dim internetdata As HTMLDocument
  
  Dim internetlink As Object
  
  Dim internetinnerlink As Object
  
  Set internet = CreateObject("InternetExplorer.Application")
  
  internet.Visible = True
  
  internet.Navigate ("URL")
  
  Do While internet.Busy
  
    DoEvents
  
  Loop
  
  Do Until internet.ReadyState = READYSTATE_COMPLETE
  
    DoEvents
  
  Loop
  
  Set internetdata = internet.Document
  
  Set internetlink = internetdata.getElementsByTagName("a")
  
  i = 1
  
  For Each internetinnerlink In internetlink
  
  ActiveSheet.Cells(i, 2) = internetinnerlink.href
  
  i = i + 1
  
  Next internetinnerlink
  
  End Sub
  </code></pre>
  
  <p>Above code takes all the links from the web page, but i need only the search result links. i have uploaded one image, if that is my webpage, i need to take only the search result links and not all the links. please help me to fix this</p>