473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

vb.net program for automatic web file download ?

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
18 16340
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
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
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
* "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
Cor
Hi Herfried,

Read the whole thread

Cor
Nov 20 '05 #6
* "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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
4
by: Bernhard | last post by:
I am not sure if php can achieve this, but i guess that my problem shoulb be solved with an server side language. Is there any way i can tell if a visitor of my website has finished a download?...
0
by: jmd | last post by:
Hello. I want to write a C# 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...
0
by: Buddy Ackerman | last post by:
I am trying to implment a file download via a link such that when clicked, instead of starting the default application for that type of file the user will be presented with a download dialog...
0
by: Rhys666 | last post by:
Basically I have a link that opens my download page and the querystring identifies the type of 'template' Excel spreadsheet has asked to download. The download page reads the querystring,...
0
by: Mahesha | last post by:
Hi All, I need to know how do we implement a file download feature in ASP.NET. As we see in the MSDN sites (say when we try to download the .NET famework) , refer this URL ...
13
by: bmurphy | last post by:
Last week after much searching, I found the answer to my problem in this newsgroup. I can't find the thread from which I got my solution, but I wanted to report back what worked. When the site...
3
by: tshad | last post by:
I have a function that downloads a file to the users computer and it works fine. The problem is that I then want the program to rename the file (file.move) to the same name plus todays date. ...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.