I'm new in Python, recently doing a school work request url from Facebook. Then I have to save the result to a text file. Here's my code, and I couldn't figure out how to save the response result. Can anyone help or point a hint? Very much appreciated.
import requests
url = "http://graph.facebook.com/{}/picture?type=large"
default = "https://static.xx.fbcdn.net/rsrc.php/v3/yl/r/HsTZSDw4avx.gif"
for user_id in range(4, 10):
response = requests.get(url.format(str(user_id)))
if response.status_code == requests.codes.ok:
if response.url != default:
print(response.url)
f = open("Output.txt", "w+", encoding = "UTF-8")
f.write(response.text)
f.close()