cruizrisner
New member
- Joined
- Jul 8, 2014
- Messages
- 2
- Programming Experience
- Beginner
I am trying to obtain a specific link in the source of a webpage
here is the actions i have for the button that is to execute the event:
and here is the part of the webpage that its retrieving from:
the issue is, it keeps giving me the false links because they appear before the correct one.
NOTE: KMU0tzLwhbE is file specific, so it changes depending on the file im going for. h=54c0c03c1c950711ce66fa8e8e840d09&r=1404821250631.1522271859 is session specific (refreshing page will change this). and h=-1&r=-1.1 (part of the fake links) is constant
here is the actions i have for the button that is to execute the event:
C#:
private void button3_Click(object sender, EventArgs e)
{
HtmlElement download_link = webBrowser1.Document.GetElementById("dl_link");
HtmlElementCollection links = download_link.GetElementsByTagName("a");
string link = links[0].GetAttribute("href");
if (link.StartsWith("http://www.sitenamehere.org/get?ab=128"))
{
webBrowser1.Navigate(link);
}
else
{
MessageBox.Show("Linking Error");
}
}
and here is the part of the webpage that its retrieving from:
HTML:
<div id="dl_link" style="display: block;">
<a style="display:none" href="/get?video_id=KMU0tzLwhbE&h=-1&r=-1.1">
<b>Download</b>
</a>
<a style="display:none" href="/get?video_id=KMU0tzLwhbE&h=-1&r=-1.1">
<b>Download</b>
</a>
<a style="display:none" href="/get?video_id=KMU0tzLwhbE&h=-1&r=-1.1">
<b>Download</b>
</a>
<a href="/get?ab=128&video_id=KMU0tzLwhbE&h=54c0c03c1c950711ce66fa8e8e840d09&r=1404821250631.1522271859">
<b>Download</b>
</a>
<a style="display:none" href="/get?video_id=KMU0tzLwhbE&h=-1&r=-1.1">
<b>Download</b>
</a>
</div>
the issue is, it keeps giving me the false links because they appear before the correct one.
NOTE: KMU0tzLwhbE is file specific, so it changes depending on the file im going for. h=54c0c03c1c950711ce66fa8e8e840d09&r=1404821250631.1522271859 is session specific (refreshing page will change this). and h=-1&r=-1.1 (part of the fake links) is constant