developedRowan
New member
- Joined
- Mar 16, 2011
- Messages
- 2
- Programming Experience
- 5-10
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:
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.
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:
VB.NET:
Public Class Form1
Public agreementPassed As [COLOR=#339999]Boolean[/COLOR] = False
Public hyperLinkList As List(Of [COLOR=#339999]String[/COLOR]) = New List(Of [COLOR=#339999]String[/COLOR])
Private Sub Button1_Click(ByVal sender As System.[COLOR=#339999]Object[/COLOR], ByVal e As System.EventArgs) Handles Button1.Click
agreementPassed = True
For Each singleLink As [COLOR=#339999]String[/COLOR] In hyperLinkList
WebBrowser1.Name = [COLOR=#800080]"pdf"
[/COLOR] WebBrowser1.Navigate(New Uri(singleLink))
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.[COLOR=#339999]Object[/COLOR], ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.Navigate(New Uri(hyperLinkList([COLOR=#000080]0[/COLOR])))
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As [COLOR=#339999]Object[/COLOR], ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If agreementPassed Then
IO.File.WriteAllText([COLOR=#800080]"C:\temp.pdf"[/COLOR], New IO.StreamReader(WebBrowser1.DocumentStream).ReadToEnd)
End If
End Sub
End Class
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.