Automate Login & File Downloading

Started by KeithW, August 01, 2022, 04:40:20 PM

Previous topic - Next topic

KeithW

Greetings,  I get so little time to play with WB&Compiler anymore that anytime I need it's assistance I feel like I am starting over at the beginning, but understand it can accomplish my needs, without fail, most every time I turn to it.  But I could use some guru assistance cause it always happens when my back is up against the wall and something needs to be done as of yesterday.

I now have to download a set of files (~20) on a weekly basis.  They are behind a login and each file is protected by a unique URL & login... the process is:
1. Enter File's URL
2. Enter Login-ID & Password
3. Save-As box appears, would be nice to be able to set/guaranteed path location, default filename is fine.  I normally use FireFox Browser and it remembers the path after the first one is done, if I have to do one manually, so be it, if this cannot be handled thru automation....
4. Close Tab
5. Repeat for remaining items

I am sure someone has already slugged thru a process like this if you can point to the pieces I need or have a sample script that you would be willing to share that would help immensely.  I have MS-Edge & Chrome on my system if FireFox is a problem.  I have put the URLs, Login-Ids and Passwords into a CSV file that I had planned to read into an array to drive the process unless you have a better suggestion as how to approach.  My biggest issue is the time frame at the moment and never having processed webforms I could use some serious direction !!

Regads,
Keith

td

HTML form automation is the subject of multiple Tech DB articles and on this forum. It would be best if you took advantage of all this existing info. To get you started here is a link to one Tech DB article:

https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/WinInet+HTTP~and~WinInet~-~An~Opus.txt

However, many other approaches include COM Automation, WinBatch CLR hosting (.Net), and browser automation using 3rd party tools with WinBatch. All these approaches have been discussed in this form. Which one you choose depends to large extent on how much javascript is in play.

You may also consider checking with the target site about using any possible REST API. If an API exists it is the recommended approach as it is usually more reliable and easier to implement.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on August 01, 2022, 05:29:12 PM

You may also consider checking with the target site about using any possible REST API. If an API exists it is the recommended approach as it is usually more reliable and easier to implement.


That would be my first choice. And, if not REST, WinHTTP query might be possible.

kdmoyers

I would add, from my humble experience, that automating web sites is often quite difficult, and each one presents a different set of challenges, even if they look similar. 
Typically the site designer is intentionally fighting your efforts, and that battle is asymmetric -- easy changes in the site can cost you days or weeks of effort.  It's brutal.  I spent a year, off and on, automating just one site.
That's why you won't find many cookie-cutter recipes for how to do it -- each case is a unique story.
Of course, your cases might be much easier -- I hope so!
The mind is everything; What you think, you become.

stanl

Would be interested in seeing how the URL is formed. If it ends with a filename the WinHttpRequest.5.1 GET might work along with request.SetCredentials "user", "password" - I recall circa 2005 using something similar to get .zip files.