Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML Code
HTML
<div id="dl_link" style="display: block;">
<a href="/get?video_id=KMU0tzLwhbE&h=-1&r=-1.1" style="display:none">Download</a>
<a href="/get?ab=128&video_id=KMU0tzLwhbE&h=f25a5baaa46941a22d89c09ee679a305&r=1405000885751.1521813114">Download</a>


So I want to retrieve the second href link in the HTML code ("/get?ab=128&video_id=KMU0tzLwhbE&h=f25a5baaa46941a22d89c09ee679a305&r=1405000885751.1521813114")

Currently what I have is this

VB
Dim link_label As HtmlElement = WebBrowser1.Document.GetElementById("dl_link")

Dim linka As HtmlElement = link_label.GetElementsByTagName("A")(0)    
Dim link As String = linka.GetAttribute("HREF")


but that only gets the first href link which is not what I want, so how do I get the second one?
Posted

This is not optimal, but you could try:

Dim linka As HtmlElement = link_label.GetElementsByTagName("A")(1)
 
Share this answer
 
What would I have to do if the code keeps changing places on different pages? How would I do it then? Changing the 0 to a 1 only works if that line of text stays in the same place each time. :(
 
Share this answer
 
Comments
CHill60 11-Jul-14 9:39am    
If you need to respond to a post use the "Have a Question or Comment?" link next to it. The member will be unaware that you are asking this question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900