-1

I was given a urls to files in CloudFront. I can access the files that I need via Chrome. Whenever I enter the url, it downloads automatically. I only enter username and password the first time to get the files (in the browser).

The url looks something like this: https://abcsdjdfhdsk.cloudfront.net/somefolderhere/anumberishere/some_really_long_file_identifer

My question is, how do I structure a requests.get request to download the files automatically. Whenever I access new files (swapping out the last part of the url, the really long id), it downloads automatically, but only in Chrome. If I clear my history and cache and try it again, I get prompted for username and password. I do not have anything else.

If I try requests.get(urlhere), then I always get a 401 error.

I can see in the web traffic that it is Amazon S3 How can I automate this with python? Do I need something more?

fixed with the following code

import requests

from requests.auth import HTTPBasicAuth

headers = {'User-Agent': 'Mozilla/5.0'}

requests.get(reallylongurl, auth=HTTPBasicAuth(username, password), headers = headers)

Wazzy24
  • 1
  • 3

1 Answers1

0

fixed with the following code

import requests

from requests.auth import HTTPBasicAuth

headers = {'User-Agent': 'Mozilla/5.0'}

requests.get(reallylongurl, auth=HTTPBasicAuth(username, password), headers = headers)

Wazzy24
  • 1
  • 3