- Published on
How to write http response to a file
- Authors
- Name
- Saad Bash
response.text
For text response: use response = requests.get("https://api.github.com/users/saadjs")
with open("response.txt", "w") as f: # 'w' for write file permission
f.write(response.text)
To append to a file:
response = requests.get("https://api.github.com/users/saadjs")
with open("response.txt", "a") as f: # 'a' for append file permission
f.write(response.text)