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

vb.net program for automatic web file download ?

P: n/a
jmd
Hello, I posted the following in the C# forum but without one answer.
But perhaps now in vb.net someone has some guidelines !
This is my question :

I want to write a vb.net program that does completely automatically what,
until

now, I do manually, witch is describe below :

1. I launch IE (6)

2. I browse to my desired download page, say
http://www.site.com/download

This download page contains some textboxes, checkboxes,

radiobuttons, a DOWNLOAD BUTTON and text

3. I check some checkboxes, select some radiobuttons, enter text in some

textboxes and click on the download button

4. I receive a File Download Dialog

I browse to select a path/filename for the file

I click on the save button

The file is then saved on my pc.

Now I want a vb.net program that does the following :

1. Browses, SILENTLY, to my desired download page
(http://www.site.com/download) and fills in a form

SILENTLY means :

. no visible browse page (I do not want to see the download page

as in IE)

. vb.net code must be able to check some checkboxes, select some

radiobuttons, enter text in some textboxes

. after filling in data, vb.net code must be able to click the
Download button

2. vb.net code must be able to trap (event) the returned data, always
SILENTLY, i.e.

must be able to trap the File Download Dialog, fills somewhere

(?) a path/filename and download the file

Hope this is comprehensible.

Any help, code/articles/HowTos.../, is welcome.

Thank you very well in advance.

Jean-Marie


Nov 20 '05 #1
Share this Question
Share on Google+
18 Replies


P: n/a
Cor
Hi Jean Marie,

My idea's to solve your problem are.

Have a look at the axwebbrowser, but do not drag it to your form, use the
Internet Explorer mode.

Have a look at the webclient.downloadfile.

Use for your second question also the Axwebbrowser, but than in the
axwebbrowser mode and than not visible.

I hope this helps?

Cor
Nov 20 '05 #2

P: n/a
jmd
Thank your for your answer.
It seems I can do the first part until file download..
The problems I still have is :
I do'nt know how to stop the File Download Dialog to appear, with
Axwebbrowser/mshtml ?
I do'nt know how to get a stream (as with
HttpWebRequest/HttpWebRespponse classes) to read the requested data, with
Axwebbrowser/mshtml ?.

Any other idea, guidelines, articles, references ?
Jean-Marie

"Cor" <no*@non.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi Jean Marie,

My idea's to solve your problem are.

Have a look at the axwebbrowser, but do not drag it to your form, use the
Internet Explorer mode.

Have a look at the webclient.downloadfile.

Use for your second question also the Axwebbrowser, but than in the
axwebbrowser mode and than not visible.

I hope this helps?

Cor

Nov 20 '05 #3

P: n/a
Cor
> I do'nt know how to stop the File Download Dialog to appear, with
Axwebbrowser/mshtml ?
I do'nt know how to get a stream (as with
HttpWebRequest/HttpWebRespponse classes) to read the requested data, with
Axwebbrowser/mshtml ?.


As I said have a look for the download to "webclient.downloadfile".

Cor

Nov 20 '05 #4

P: n/a
* "jmd" <no******************@iesn.be> scripsit:
It seems I can do the first part until file download..
The problems I still have is :
I do'nt know how to stop the File Download Dialog to appear, with
Axwebbrowser/mshtml ?
I do'nt know how to get a stream (as with
HttpWebRequest/HttpWebRespponse classes) to read the requested data, with
Axwebbrowser/mshtml ?.


Why do you need to utilize the webbrowser to download the file?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

P: n/a
Cor
Hi Herfried,

Read the whole thread

Cor
Nov 20 '05 #6

P: n/a
* "Cor" <no*@non.com> scripsit:
Read the whole thread


I read it.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

P: n/a
Addendum:
Read the whole thread


I read it.


Better: I read everything my newsreader showed me :-(((

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #8

P: n/a
Cor
Herfried,

At your service,

This is the starting question,

now, I do manually, witch is describe below :
1. I launch IE (6)
2. I browse to my desired download page, say
http://www.site.com/download
This download page contains some textboxes, checkboxes,
radiobuttons, a DOWNLOAD BUTTON and text
3. I check some checkboxes, select some radiobuttons, enter text in some
textboxes and click on the download button
4. I receive a File Download Dialog
I browse to select a path/filename for the file
I click on the save button

So my opinion is AXwebbrowser and than download with webclient.downloadfile

There are thousand other approaches of course but this comes in my opinion
the nearest to the question.

:-).

Cor

Nov 20 '05 #9

P: n/a
jmd
Thank you.
(I must admit than I am relatively new in this domain of web, http and
similar)
I looked at the WebClient class.
But I do not know how to use this class to :
1. Suppress the File Dialog Box I receive after I simulated the
download click() button in my code ?
2. Get a stream to the data (data are csv lines of ascii values) in my
code ?
I thought that the simulation of the download click() button in my code
could generate an event (but which one ?) where I could perhaps resolve the
2 points above ?
Jean-Marie

rem : excuse my english language, it's not my native one.

"Cor" <no*@non.com> wrote in message
news:u8**************@tk2msftngp13.phx.gbl...
I do'nt know how to stop the File Download Dialog to appear, with
Axwebbrowser/mshtml ?
I do'nt know how to get a stream (as with
HttpWebRequest/HttpWebRespponse classes) to read the requested data, with Axwebbrowser/mshtml ?.


As I said have a look for the download to "webclient.downloadfile".

Cor

Nov 20 '05 #10

P: n/a
Cor
Hi Jean-Marie,

This is all to use the webclient to download a file,

Dim wbc As New System.Net.WebClient
wbc.DownloadFile(Url, DiskFilename)

I hope this helps, but if I do not understand your question feel free to
ask?

Cor
Nov 20 '05 #11

P: n/a
jmd
Hi.
Yes I know : wbc.DownloadFile(Url, DiskFilename)
But the filename is first generated by the web site and is dependent of the
controls I clicked on the form before sending the request to the web site by
simulating a click on a button (labeled Download).
I see this generated filename through the File Download Dialog Box received
after the click above.
I would like to trap this dialog (I do not want it appeared on the screen)
in my code, perhaps by setting an event handler that would be fired to
signal data receive from the web site and that would permits me (from
axWebBrowser or other control ?)
1) to stop the display of the File Download Dialog and
2) to get a stream to read the data (as WebResponse.GetResponseStream()
does)
Hope I am clear !
Thank you.
Jean-Marie.

"Cor" <no*@non.com> wrote in message
news:ug****************@TK2MSFTNGP10.phx.gbl...
Hi Jean-Marie,

This is all to use the webclient to download a file,

Dim wbc As New System.Net.WebClient
wbc.DownloadFile(Url, DiskFilename)

I hope this helps, but if I do not understand your question feel free to
ask?

Cor

Nov 20 '05 #12

P: n/a
jmd
Hi.
The button is on the webpage (webform, see my first post).
(french term "telecharger" = english term "download")
A View Source in IE gives it :
----------
<td width="112">
<input type="image" name="ImageButton1" id="ImageButton1"
src="http://www.abcbourse.com/cotations/i/telecharger.gif" border="0"
/></td>
----------
Actually my test code is (from a sample found on the web):
public static void OpenBrowser(string url) // <== url is passed
http://download.abcbourse.com/metastock_jour.aspx
{
object o = null;
InternetExplorer ie = null;
try {
ie = new InternetExplorerClass();
IWebBrowserApp wb = (IWebBrowserApp) ie;
wb.Navigate(url, ref o, ref o, ref o, ref o);
while (wb.Busy);

HTMLDocument wd = (HTMLDocument)wb.Document;
// ===> check a CheckBox named "srdp"
HTMLInputElement cbxSrd = (HTMLInputElement) wd.all.item("srdp", 0);
((mshtml.HTMLInputElementClass)cbxSrd).click();
// ===> click the download button named "ImageButton1"
HTMLInputElement btnTelecharger = (HTMLInputElement)
wd.all.item("ImageButton1", 0);
btnTelecharger.click();

while (wb.Busy);
// .===> What to do here ?

}
finally
{
if (ie != null) ie.Quit();
}
}
// ===> from here I would like to have perhaps an event method to trap the
File Downlad Dialog Box ....

Jean-Marie.
"Cor" <no*@non.com> wrote in message
news:uF**************@TK2MSFTNGP11.phx.gbl...
Hi Jean Marie,

For me now is the problem, where is the button that you use to download, is that on a windowform or is it in the webpage.

If it is in the webpage it is hard to get that button.
(not impossible but that I cannot describe in the context of a newsgroup
answer (also not in a mail).

If it is on a windowform, than there should be a click event and in that
click event you have to do it.

Paste a little piece of code in where you have that button yoy are talking
about (first to a notebook and than copy from there and than in the message otherwise it is unreadable).

Maybe I can look at it tomorrow. (I stop with the newsgroup in some minutes)
Cor

Nov 20 '05 #13

P: n/a
Cor
Hi Jean Marie,

This was your first question
Now I want a vb.net program that does the following :
Now you say the button is on the webpage, this does not sounds as a vb.net
program.

It seems more and more for me that you want a program on your client side
that loads things from the Server.

If you use for that IE it is not posible to things silently.
That is where Microsoft spent millions and millions for to let that not
happen because if you can do that with a image you can do that with
everything.

Is that what you had in mind (not the virus of course) but let the client
upload silently things from your server?

Cor

The button is on the webpage (webform, see my first post).
(french term "telecharger" = english term "download")
A View Source in IE gives it :
----------
<td width="112">
<input type="image" name="ImageButton1" id="ImageButton1"
src="http://www.abcbourse.com/cotations/i/telecharger.gif" border="0"
/></td>
----------
Actually my test code is (from a sample found on the web):
public static void OpenBrowser(string url) // <== url is passed
http://download.abcbourse.com/metastock_jour.aspx
{
object o = null;
InternetExplorer ie = null;
try {
ie = new InternetExplorerClass();
IWebBrowserApp wb = (IWebBrowserApp) ie;
wb.Navigate(url, ref o, ref o, ref o, ref o);
while (wb.Busy);

HTMLDocument wd = (HTMLDocument)wb.Document;
// ===> check a CheckBox named "srdp"
HTMLInputElement cbxSrd = (HTMLInputElement) wd.all.item("srdp", 0);
((mshtml.HTMLInputElementClass)cbxSrd).click();
// ===> click the download button named "ImageButton1"
HTMLInputElement btnTelecharger = (HTMLInputElement)
wd.all.item("ImageButton1", 0);
btnTelecharger.click();

while (wb.Busy);
// .===> What to do here ?

}
finally
{
if (ie != null) ie.Quit();
}
}
// ===> from here I would like to have perhaps an event method to trap the
File Downlad Dialog Box ....

Nov 20 '05 #14

P: n/a
jmd
Hi Cor,

Actually, I download text data from a web site to a file on my pc and I do
this MANUALLY (see my first post).
I want to write a vb.net or C# program that will do this download
AUTOMATICALLY.
This program must be able, SILENTLY, to :
1. connect to a web site (with axWebBrowser, mshtml,
WebRequest/WebResponse classes or other control...).
I can do this with axWebBrowser, also with
WebRequest/WebResponse.
2. receive from 1. above a HTMLDocument and fill in checkboxes,
radiobuttons and textboxes.
I can do this using axWebBrowser + mshtml.
3. simulate a Click on a Submit/Download button to send the filled
web form (in 2. above) to the web site.
I can also do this using mshtml as in 2. above.
4. receive the data (csv ascii text) as a response from the web
site.
I CANNOT DO this last step.
I want here to capture the response from the web site as a
stream, read the stream and fill a DataTable with the csv data.

The last question is :
Having instantiated a WebBrowser object, send a request for data to a
web site, how can I capture the response from this web site in my program
code, without any user prompts/actions ?

Hope this is more clear ?
Thank you very much for your time to help me.
Jean-Marie.

"Cor" <no*@non.com> wrote in message
news:un**************@tk2msftngp13.phx.gbl...
Hi Jean Marie,

This was your first question
Now I want a vb.net program that does the following :


Now you say the button is on the webpage, this does not sounds as a vb.net
program.

It seems more and more for me that you want a program on your client side
that loads things from the Server.

If you use for that IE it is not posible to things silently.
That is where Microsoft spent millions and millions for to let that not
happen because if you can do that with a image you can do that with
everything.

Is that what you had in mind (not the virus of course) but let the client
upload silently things from your server?

Cor

The button is on the webpage (webform, see my first post).
(french term "telecharger" = english term "download")
A View Source in IE gives it :
----------
<td width="112">
<input type="image" name="ImageButton1" id="ImageButton1"
src="http://www.abcbourse.com/cotations/i/telecharger.gif" border="0"
/></td>
----------
Actually my test code is (from a sample found on the web):
public static void OpenBrowser(string url) // <== url is passed
http://download.abcbourse.com/metastock_jour.aspx
{
object o = null;
InternetExplorer ie = null;
try {
ie = new InternetExplorerClass();
IWebBrowserApp wb = (IWebBrowserApp) ie;
wb.Navigate(url, ref o, ref o, ref o, ref o);
while (wb.Busy);

HTMLDocument wd = (HTMLDocument)wb.Document;
// ===> check a CheckBox named "srdp"
HTMLInputElement cbxSrd = (HTMLInputElement) wd.all.item("srdp", 0);
((mshtml.HTMLInputElementClass)cbxSrd).click();
// ===> click the download button named "ImageButton1"
HTMLInputElement btnTelecharger = (HTMLInputElement)
wd.all.item("ImageButton1", 0);
btnTelecharger.click();

while (wb.Busy);
// .===> What to do here ?

}
finally
{
if (ie != null) ie.Quit();
}
}
// ===> from here I would like to have perhaps an event method to trap the File Downlad Dialog Box ....


Nov 20 '05 #15

P: n/a
Cor
Hi Jean Marie,

What is the proces you describe
1. connect to a web site (with axWebBrowser, mshtml,
WebRequest/WebResponse classes or other control...). You ask to a server a webpage
2. receive from 1. above a HTMLDocument and fill in checkboxes,
radiobuttons and textboxes. You get on your screen or with Mshtml documents

3. simulate a Click on a Submit/Download button to send the filled web form (in 2. above) to the web site. You fill automaticly the document and even can do a click (I never did this
part) the click, submit your page to the website.
4. receive the data (csv ascii text) as a response from the web
site.

And now I miss something, because the submit button is another button than a
download button (A anchor with a file url and an image). They both take
direct action and this should be more steps.

I think I reach what you want to do but still am not there.

Cor

Nov 20 '05 #16

P: n/a
jmd
Hi Cor.
The points 1., 2. and 3. are ok. They are are just as you describe.
And yes, the problem is with point 4.
When I talk about a Submit/Download/Telecharger button I mean clicking on an
image corresponding on the web page to (see a preceeding post) :
----------
<td width="112">
<input type="image" name="ImageButton1" id="ImageButton1"
src="http://www.abcbourse.com/cotations/i/telecharger.gif" border="0"
/></td>
----------
After that click (manually or by code) I receive a File Download dialog in
the middle of the screen.
INSTEAD OF THIS DIALOG, I would like to have an event fired in my program
code when the requested data from the web site is available.
In this event I could get a stream to read the data in a String variable for
example
and do whatever I want after that.
But I do no know if this is possible and if it's possible, how to do this !

I will continue to dig around.
Thank you for your help.
Jean-Marie.

"Cor" <no*@non.com> wrote in message
news:uM**************@TK2MSFTNGP11.phx.gbl...
Hi Jean Marie,

What is the proces you describe
1. connect to a web site (with axWebBrowser, mshtml,
WebRequest/WebResponse classes or other control...). You ask to a server a webpage
2. receive from 1. above a HTMLDocument and fill in checkboxes,
radiobuttons and textboxes.

You get on your screen or with Mshtml documents

3. simulate a Click on a Submit/Download button to send the filled
web form (in 2. above) to the web site.

You fill automaticly the document and even can do a click (I never did

this part) the click, submit your page to the website.
4. receive the data (csv ascii text) as a response from the web
site. And now I miss something, because the submit button is another button than

a download button (A anchor with a file url and an image). They both take
direct action and this should be more steps.

I think I reach what you want to do but still am not there.

Cor

Nov 20 '05 #17

P: n/a
Cor
Hi Jean Marie,

I did try to tell you this before I will do it in more words although that
is not always better.
Hi Jean Marie,
---------------------------------------------
Your Question:
When I talk about a Submit/Download/Telecharger button I mean clicking on an
image corresponding on the web page to (see a preceeding post)
After that click (manually or by code) I receive a File Download dialog in
the middle of the screen.
INSTEAD OF THIS DIALOG, I would like to have an event fired in my program
code when the requested data from the web site is available.
In this event I could get a stream to read the data in a String variable for
example and do whatever I want after that.
-----------------------------------------------
I did try to tell you this before I will do it in more words although that
is not always better.

The axwebbrowser is nothing more than a connection to Internet Explorer.

One of the most protected things with Internet Explorer is that there never
can be a download unattended on your computer.

There has been much effort to download by instance autodialers on computers,
the same, as there is much effort to prevent those actions.

What you want, is something, what is much wanted by people who want to earn
illegal money, when it becomes possible, than almost in the same time you
can get a security patch to make it impossible.

That makes it of course also impossible for people who want to use this
legally.

I hope I did explain it right to you?

Cor
Nov 20 '05 #18

P: n/a
jmd
Ok.
I understand your point of view.
Thank you very much for all your help and time
Jean-Marie.

"Cor" <no*@non.com> wrote in message
news:u%****************@tk2msftngp13.phx.gbl...
Hi Jean Marie,

I did try to tell you this before I will do it in more words although that
is not always better.
Hi Jean Marie,
---------------------------------------------
Your Question:
When I talk about a Submit/Download/Telecharger button I mean clicking on an image corresponding on the web page to (see a preceeding post)
After that click (manually or by code) I receive a File Download dialog in
the middle of the screen.
INSTEAD OF THIS DIALOG, I would like to have an event fired in my program
code when the requested data from the web site is available.
In this event I could get a stream to read the data in a String variable for example and do whatever I want after that.
-----------------------------------------------
I did try to tell you this before I will do it in more words although that
is not always better.

The axwebbrowser is nothing more than a connection to Internet Explorer.

One of the most protected things with Internet Explorer is that there never can be a download unattended on your computer.

There has been much effort to download by instance autodialers on computers, the same, as there is much effort to prevent those actions.

What you want, is something, what is much wanted by people who want to earn illegal money, when it becomes possible, than almost in the same time you
can get a security patch to make it impossible.

That makes it of course also impossible for people who want to use this
legally.

I hope I did explain it right to you?

Cor

Nov 20 '05 #19

This discussion thread is closed

Replies have been disabled for this discussion.