Sending the variable's content to my mailbox in Python?

Posted by brilliant on Stack Overflow See other posts from Stack Overflow or by brilliant
Published on 2009-12-11T18:14:51Z Indexed on 2010/05/04 1:18 UTC
Read the original article Hit count: 288

I have asked this question here about a Python command that fetches a URL of a web page and stores it in a variable. The first thing that I wanted to know then was whether or not the variable in this code contains the HTML code of a web-page:

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

The answer that I received was "yes", i.e. the variable "result" in the code did contain the HTML code of a web page, and the programmer who was answering said that I needed to "check the Content-Type header and verify that it's either text/html or application/xhtml+xml". I've looked through several Python tutorials, but couldn't find anything about headers. So my question is where is this Content-Type header located and how can I check it? Could I send the content of that variable directly to my mailbox?

Here is where I got this code. It's on Google App Engines.

© Stack Overflow or respective owner

Related posts about python

Related posts about url