title: Saving the request response url to a text file
body: <p>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.</p>
  <pre><code>import requests
  
  url = &quot;http://graph.facebook.com/{}/picture?type=large&quot;
  default = &quot;https://static.xx.fbcdn.net/rsrc.php/v3/yl/r/HsTZSDw4avx.gif&quot;
  
  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(&quot;Output.txt&quot;, &quot;w+&quot;, encoding = &quot;UTF-8&quot;)
  f.write(response.text)
  f.close()
  </code></pre>