'Script that signs in, captures the session cookie, then uses that to download a file

Newbie here, quite possibly out of my depth...

I need to schedule a file to be downloaded to then upload to GoogleSheets. Otherwise, I'm manually exporting and uploading the file 3 times a day over the summer :-(

I've been 'given' the script:

"Script to sign in and download the file

curl --cookie cookies.txt --cookie-jar cookies.txt --output signin.html --data "email=&password=" https://WEBSITE.co.uk/xxx/signin_password curl --cookie cookies.txt --output file.csv https://WEBSITE.co.uk//xxx/download_members The first command signs in and grabs a session cookie and the second fetches the file. The session cookie will timeout after 60 mins of inactivity.

Browser Verification - Script to fetch the verification cookie

You will need an additional script to fetch the verification cookie that can then be used for download.

Run the download script above which will fail the first time due to browser verification - but send you a verification email.

Copy/paste the link from the verification email into the following:

curl --cookie-jar cookies.txt --output verify.html "" This will fetch the verification cookie and store it in cookie.txt used by the download script. Note that the verification link can only be used once.

It should now be possible to re-run the download script without the need for verification. If there is a long period (over a month) between downloads you may need to obtain a new verification cookie. If the email address or password used for the download is changed a new verification cookie will be required."

I'm using Windows PowerShell ISE but keep getting the error "Invoke-WebRequest : A positional parameter cannot be found that accepts argument 'cookies.txt'."

Any help would be much appreciated. I'm helping out a local charity...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source