title: Is there anything wrong with this Google App Engine url-fetching code that I have here?
body: <p>When I view the source of the page in my browser (FireFox) (View->Page Source), copy it and paste it into my HTML editor, I view almost the same page (In this example it is www.google.com) as it appears in my browser. But when I get the HTML source through this code (through Googles App Engines)</p>
  
  <pre><code>from google.appengine.api import urlfetch
  url = "http://www.google.com/"
  result = urlfetch.fetch(url)
  if result.status_code == 200:
     print result.content
  </code></pre>
  
  <p>copy it and paste it into my HTML editor, the page then looks quite different. Why is it so? Is there something wrong with the code? </p>
  
  <p>++++++++++++++++++++++++++++++</p>
  
  <p>Follow-up:</p>
  
  <p>By this moment (Sunday, December 13th, 2009, 1:01 PM, GMT, to be precise) I have received two comments-questions (from <strong>Aaron</strong> and <strong>Christian P.</strong>) and one answer from <strong>Alex Martelli</strong>.</p>
  
  <p>Both <strong>Aaron</strong> and <strong>Christian P.</strong> are asking about what actually is different between the Fire-Fox-obtained source and Google-App-Engine-obtained source when they are both displayed through the same HTML editor. </p>
  
  <p>Here I have uploaded too screen shots:</p>
  
  <p><a href="http://roundcan.narod.ru/HTML_source_from_Fire_Fox.jpg" rel="nofollow noreferrer">One shows the Fire-Fox-obtained source</a></p>
  
  <p>And <a href="http://roundcan.narod.ru/HTML_source_from_Google_App_Engine.jpg" rel="nofollow noreferrer">the other one shows Google-App-Engine-obtained source</a></p>
  
  <p>when they are both displayed through  “MS Front Page” editor. </p>
  
  <p>One difference, which is quite obvious, is different encoding: In Fire-Fox code everything is displayed in English, while in the Google-App-Engine code I get a lot of various symbols, instead.</p>
  
  <p>Another difference is some additional lines at the top of the page in the Google App Engine code. I think, this is what <strong>Alex Martelli</strong> was talking about in his answer (“…the fetch-and-print approach is going to have metadata around it as well…”).</p>
  
  <p>One more minor difference is that the box for the Google image is split into several boxes in one code, while it remains whole in the other one.</p>
  
  <p><strong>Alex Martelli</strong> suggested that I use this code (if I understood him correctly):</p>
  
  <pre><code>from google.appengine.api import urlfetch
  url = "http://www.google.com/"
  result = urlfetch.fetch(url)
  if result.status_code == 200:
     print "content-type: text/plain"
     print
  </code></pre>
  
  <p>I’ve tried it, but in this case nothing is displayed at all.</p>
  
  <p>Thank you all for your responses and, please, continue responding – I really want to see this issue finally resolved.</p>
  
  <p>++++++++++++++++++++++++++++++</p>
  
  <p>Follow-up:</p>
  
  <p>Okay, the issue has been resolved. </p>
  
  <p>I failed to pay my full attention to <strong>Alex Martelli</strong>'s instructions and, therefore, came up with a wrong code. Here is he right one:</p>
  
  <pre><code>from google.appengine.api import urlfetch
  url = "http://www.google.com/"
  result = urlfetch.fetch(url)
  if result.status_code == 200:
     print "content-type: text/plain"
     print
     print result.content
  </code></pre>
  
  <p>This code displays exactly what is needed - no additional lines at the top of the page.</p>
  
  <p>Well, I still get the strange symbols, but I discovered that it's probably Google's problem. The thing is I am currently in Taiwan, and Google seems to be aware of that and automatically switches from www.google.com (which is in English) to www.google.com.tw (which is in Chinese), but this one, I guess, is already another topic.</p>
  
  <p>Thanks to everyone who has responded here.</p>