Take the 2-minute tour ×

On Google App Engine I found this code that is fetching a web page's URL:

from google.appengine.api import urlfetch
url = "http://www.google.com/"
result = urlfetch.fetch(url)
if result.status_code == 200:

Is this the right code to fecth that page's HTML source? Does the result variable contain HTML sorce of http://www.google.com/? If yes, what Python command I should use here instead of doSomethingWithResult(result.content) in order to display that HTML source? print result doesn't seem to be the right way.

share|improve this question
Did it worked for you ?The code not working for me ! –  Prashant Singh Feb 8 '13 at 12:48

1 Answer 1

up vote 5 down vote accepted

Yes, result.content will contain the raw content of that page. You should check the Content-Type header and verify that it's either text/html or application/xhtml+xml.

To write the content of that page to the response, first write your status and headers and then:

share|improve this answer
Thank you very much, Bob!!! –  brilliant Dec 8 '09 at 17:57
You're quite welcome! –  Bob Aman Dec 8 '09 at 18:41

Your Answer


