By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,552 Members | 905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,552 IT Pros & Developers. It's quick & easy.

Automatically download and save pdf files from a website.

P: n/a
MJ
Automatically download and save pdf files from a website.

Is there a way to do this?

I would like to automate a daily procedure for downloading and saving a
couple of dozen pdf from several websites. Currently I have saved bookmarks
in a browser and manually open and save each one.

Some of the files have direct addresses, for example:
https://www.somewebsite.com/resource...rice_sheet.pdf

Some are dynamically generated, for example:
https://www.somewebsite.com/resource...te=MA&type=wsl
(this returns a pdf file to the browser)
I can get the directly addressed documents with some simple scripting of an
FTP client. It's the dynamically generated files that I'm having a hard time
figuring out. The only way I've been able to get the dymamically generated
files seems to be to request the url through a browser.
(Windows XP pro, ie 6.0, Acrobat Reader 7.0.0, VB.NET 2003)
Dim ieApp As SHDocVw.InternetExplorer = New SHDocVw.InternetExplorer
Dim sURL as String = "URL of file I want"
ieApp.Navigate(sURL)

This seems to work fine. Launches a browser, navigates to the URL, browser
invokes Acrobat, pdf document is displayed.

The two problems I don't know how to solve are:

1) Determining when the pdf document has finished downloading.
2) Saving it.
Thanks.

Mike


Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"MJ" <no**@nomail.com> schrieb:
Automatically download and save pdf files from a website.

'WebClient.DownloadFile'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2

P: n/a
Mike,

Here is some of my C# code that I use. Should be very easy to translate
into VB.NET. Give it a try and let me know how it goes.

WebClient webClient = new WebClient();
try
{
webClient.Credentials = CredentialCache.DefaultCredentials;
webClient.DownloadFile(url, fileName);
}
catch (System.Exception e)
{
// Do something with exception
}
finally
{
webClient.Dispose();
}
Jason Newell
MJ wrote:
Automatically download and save pdf files from a website.

Is there a way to do this?

I would like to automate a daily procedure for downloading and saving a
couple of dozen pdf from several websites. Currently I have saved bookmarks
in a browser and manually open and save each one.

Some of the files have direct addresses, for example:
https://www.somewebsite.com/resource...rice_sheet.pdf

Some are dynamically generated, for example:
https://www.somewebsite.com/resource...te=MA&type=wsl
(this returns a pdf file to the browser)
I can get the directly addressed documents with some simple scripting of an
FTP client. It's the dynamically generated files that I'm having a hard time
figuring out. The only way I've been able to get the dymamically generated
files seems to be to request the url through a browser.
(Windows XP pro, ie 6.0, Acrobat Reader 7.0.0, VB.NET 2003)
Dim ieApp As SHDocVw.InternetExplorer = New SHDocVw.InternetExplorer
Dim sURL as String = "URL of file I want"
ieApp.Navigate(sURL)

This seems to work fine. Launches a browser, navigates to the URL, browser
invokes Acrobat, pdf document is displayed.

The two problems I don't know how to solve are:

1) Determining when the pdf document has finished downloading.
2) Saving it.
Thanks.

Mike


Nov 21 '05 #3

P: n/a
MJ
Thanks a million Jason & Herfried. That's exactly what I was looking for. I
had no idea it was there (is my newbieness showing?).

Thanks again,
Mike


"Jason Newell" <no****@nospam.com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Mike,

Here is some of my C# code that I use. Should be very easy to translate
into VB.NET. Give it a try and let me know how it goes.

WebClient webClient = new WebClient();
try
{
webClient.Credentials = CredentialCache.DefaultCredentials;
webClient.DownloadFile(url, fileName);
}
catch (System.Exception e)
{
// Do something with exception
}
finally
{
webClient.Dispose();
}
Jason Newell
MJ wrote:
Automatically download and save pdf files from a website.

Is there a way to do this?

I would like to automate a daily procedure for downloading and saving a
couple of dozen pdf from several websites. Currently I have saved
bookmarks
in a browser and manually open and save each one.

Some of the files have direct addresses, for example:
https://www.somewebsite.com/resource...rice_sheet.pdf

Some are dynamically generated, for example:
https://www.somewebsite.com/resource...te=MA&type=wsl
(this returns a pdf file to the browser)
I can get the directly addressed documents with some simple scripting of
an FTP client. It's the dynamically generated files that I'm having a
hard time figuring out. The only way I've been able to get the
dymamically generated files seems to be to request the url through a
browser.
(Windows XP pro, ie 6.0, Acrobat Reader 7.0.0, VB.NET 2003)
Dim ieApp As SHDocVw.InternetExplorer = New SHDocVw.InternetExplorer
Dim sURL as String = "URL of file I want"
ieApp.Navigate(sURL)

This seems to work fine. Launches a browser, navigates to the URL,
browser invokes Acrobat, pdf document is displayed.

The two problems I don't know how to solve are:

1) Determining when the pdf document has finished downloading.
2) Saving it.
Thanks.

Mike



Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.