Here is my situation: I have to login to a Website and download a CSV from there, headless from a linux server. The page uses JS and does not work without it.
After
You can try something like:
from requests.auth import HTTPBasicAuth
import requests
url = "http://some_site/files?file=file.csv" # URL used to download file
# GET-request to get file content using your web-site's credentials to access file
r = requests.get(url, auth=HTTPBasicAuth("your_username", "your_password"))
# Saving response content to file on your computer
with open("path/to/folder/to/save/file/filename.csv", 'w') as my_file:
my_file.write(r.content)