I need to download a list of PDF files from an Australian Government website, and i dont want to download them manually, so i need a program to download them.
The website we are requiring documents from is: https://www.ebs.tga.gov.au/ebs/picmi/picmirepository.nsf/PICMI?OpenForm&k=A
Below is my current code:
Public Class Form1
Public agreementPassed As Boolean = False
Public hyperLinkList As List(Of String) = New List(Of String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
agreementPassed = True
For Each singleLink As String In hyperLinkList
WebBrowser1.Name = "pdf"
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If agreementPassed Then
IO.File.WriteAllText("C:\temp.pdf", New IO.StreamReader(WebBrowser1.DocumentStream).ReadToEnd)
I populate the LinkedList by another button i havn't included, but that works. Button 2 is used to just display the first page to agree to the conditions and generate the cookie. When i click Button1 its meant to save each link. All that happens though is the last URL opens the PDF in Adobe outside of the program and the HTML page that is seen when you need to click "I Agree" is saved to Temp.pdf.
I'm open to any ideas on how to do this, and if i need to get rid of the WebBrowser, i'm happy to do that too.