web browser navigation and downloading - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


web browser navigation and downloading

cruizrisnercruizrisner Posts: 7Member

I am trying to make an application that works with a well known youtube-mp3 converter to download the mp3 file without visiting the site (much more to add to the program later for easy of use but i need to get past my issue that im at now first, this is not a complete application ready for release)

first off, this is a windows form application and requires textBox1, webBrowser1, button1, button2, and button3

the issue: it seems to be working properly until button 3 (the actual download). it just refreshes the page that the browser is currently on as if it didnt put the whole fetched url in. however if u go into your normal browser, look up the source, copy the link from where it fetches it, and put it in your URL bar, it works. so i dont understand why my program isnt working. (also note that if i physically click download in the browser window in my application it works o.0 )

and here is the source:

` using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace YTMP3
public partial class Form1 : Form

public Form1()


private void button1_Click(object sender, EventArgs e)

if (textBox1.Text.StartsWith("https://www.youtube.com/watch?v="))
button2.Enabled = true;
button2.Enabled = false;

private void button2_Click(object sender, EventArgs e)
webBrowser1.Document.GetElementById("youtube-url").SetAttribute("value", textBox1.Text);
button3.Enabled = true;

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");

private void textBox1_TextChanged(object sender, EventArgs e)


private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)

anyone with some feedback? please and thank you


  • cruizrisnercruizrisner Posts: 7Member

    ah i think i figured out why. the website added a small prevention mechanism by adding multiple bunk href links (not visible or clickable) so that the program would gather them instead. anyway i can get my program to ignore them?

Sign In or Register to comment.