download a pdf from a website - Vb.net

I am working on a program that visits a website, log's that websites login page which takes it to a pdf document that i need to download automatically with a preset path, then move on to the next link.

The only way i can make this function currently is using the axwebbrowser, calling this command:
wbrbrowser.ExecWB(SHDocVw.OLECMDID.OLECMDID_SAVEAS, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, "asfdffffff.pdf", "asfdddddd.pdf")
Then sending keys with the path and hitting enter....
as the dontpromtuser call does not work. (this has been discussed elsewhere in the forum)

I have also tried the sysem.net.webclient

Dim getfile As System.Net.WebClient
getfile = New System.Net.WebClient

getfile.DownloadFile("https://ecf.ohsd.uscourts.gov/cgi-bin/show_case_doc?pdf_header=2&magic_num=" & MAGIC_NUM & "&case_id=" & CASE_ID & "&doc_num=" & DOC_NUMBER & "&att_num=" & i & "&got_receipt=1", "C:\testthispdf.pdf")

However, the file that is downloaded is currupt and will not open.

If anyone can provide an alternitive method, or possibly something i am doing wrong with either of these two, i would greatly appreciate it.

Thank you,
Devlin
DevlinmcAsked:
Who is Participating?
 
dave4dlConnect With a Mentor Commented:
check out http://msdn.microsoft.com/msdnmag/issues/02/10/spiderinnet/ for more info

just treat the pdf as you would any binary file (meaning you don't want to interpret it) and stream it to a destination file.
0
 
dave4dlCommented:
you should be using the System.Net.HttpWebRequest and System.Net.HttpWebResponse objects to build your spider.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.