B
Brian Tkatch
Guest
I am working on a program to automate downloading PDFs from a secure website to help the people in the office get the files faster. These are reports that need to be generated daily, and merely the clicking and waiting for each report wastes a lot of time. So, having a program login and download it for them would be a great help.
The website uses a lot of javascript and POSTs, so GET is not an option. (I tried a few GETs myself and failed.) So i go to the login page, fill in the username and password fields, invoke click on the login button, go to the report URL (an xhtml file with parameters) which brings up an options page, and invoke the click event on the button. Going directly to the url provided by the button or the url of the report, fails with an error message about rights. It would seem i must invoke the click event and wait for the PDF to be served.
When i go there in Chrome, the PDF loads in the same tab and i can save the file like any PDF. When i go there in VB, the browser times out on the last step. I verified it went to the options page (by saving the document and checking) so everything until there works fine. When i used the browser control myself to click the button manually, it brought up a second tab and displayed a save file dialog.
Is there a way to download the file without the dialog?
As for the IE version, i am using IE11, set in the registry before the control is used:
Dim Key = "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION"
Dim Value = IO.Path.GetFileName(Application.ExecutablePath) ' The name of this program must be the value.
Dim IE11 = 11001
If Not My.Computer.Registry.GetValue(Key, Value, vbNull).Equals(IE11) Then My.Computer.Registry.SetValue(Key, Value, IE11, Microsoft.Win32.RegistryValueKind.DWord)
I did some searching and found one person using a webclient, and another using SendKeys. Is there a simpler way?
Continue reading...
The website uses a lot of javascript and POSTs, so GET is not an option. (I tried a few GETs myself and failed.) So i go to the login page, fill in the username and password fields, invoke click on the login button, go to the report URL (an xhtml file with parameters) which brings up an options page, and invoke the click event on the button. Going directly to the url provided by the button or the url of the report, fails with an error message about rights. It would seem i must invoke the click event and wait for the PDF to be served.
When i go there in Chrome, the PDF loads in the same tab and i can save the file like any PDF. When i go there in VB, the browser times out on the last step. I verified it went to the options page (by saving the document and checking) so everything until there works fine. When i used the browser control myself to click the button manually, it brought up a second tab and displayed a save file dialog.
Is there a way to download the file without the dialog?
As for the IE version, i am using IE11, set in the registry before the control is used:
Dim Key = "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION"
Dim Value = IO.Path.GetFileName(Application.ExecutablePath) ' The name of this program must be the value.
Dim IE11 = 11001
If Not My.Computer.Registry.GetValue(Key, Value, vbNull).Equals(IE11) Then My.Computer.Registry.SetValue(Key, Value, IE11, Microsoft.Win32.RegistryValueKind.DWord)
I did some searching and found one person using a webclient, and another using SendKeys. Is there a simpler way?
Continue reading...