Write text file
response = requests.get("https://somedomain.com/somepage", timeout=10) #Timeout in secs, Get something you want to store
file1 = open("response.txt", "w")
file1.write(response.text)
file1.close()
//Or, using with (handles close for you whatever happens):
with open("response.txt", "w") as file1:
file1.write(response.text)
Write binary file
# Request the profile picture of the OP:
response = requests.get("https://somedomain.com/someimage.jpg", timeout=10) #Timeout in secs, Get a file you want to store
file1 = open("response.jpg", "wb")
file1.write(response.content)
file1.close()
//Or, using with (handles close for you whatever happens)
with open("response.jpg", "wb") as file1:
file1.write(response.content)
