I would like to invoke a click on a link from a link that is generated by an HTML query. I am attempting to program an application that queries a website and am getting hung up where I download the .csv that is loaded by the website. Here is the link I am trying to read:

<a href="http://www5.statcan.gc.ca/cansim/results/cansim9170974256855749928.csv">Download file from CANSIM (CSV Version, 5<abbr title="kilobyte">kb</abbr>)</a>

cansim9170974256855749928 from the url is not static and I don't know how to work around this. I thought that this link would be helpful and should be except there is no link ID to reference. Is there a way to enable a clicking event on a random csv link? I have mashed together some failing attempts at this off and on for some time now and am now in your hands. All I have for code to show after all attempts is:

With WebBrowser1.Document


End With

Any guidance would be most apreciated.

PS: While I am a student this is not student related, it's a personal/work related aproach to ad hoc data retrieval.

Recommended Answers

All 4 Replies

With WebBrowser1.Document
End With

I can no longer edit my first post so:

Cross Posted Here

Please do read the Member rules before posting....Click Here

Sorry about the cross post, I thought it was a generic forum rule to always show a cross post. It won't happen again.

Woohoo, the following code does exactly as I need it to:

For Each link As HtmlElement In WebBrowser1.Document.Links
   If link.InnerText.Contains("Download file from CANSIM") Then
      WebBrowser1.Navigate(link.GetAttribute("href"))
   End If
Next
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.