Possibility and Probability

Coding Python and making businesses…

9 March 2005

A nice little quickie

by Nick

Along the lines of doing any amount of coding in any amount of time you have, I wanted to share this little nugget. I’m sure everyone who’s been using python for more than 10 minutes knows this, but I find it so useful.

Say you want to test something out like an HTML parser. Instead of hammering th sever 5 million times while you figure out what data you want to pull of the page, save the page to you local machine. Then in the directory where you saved the HTML file start up python (from the command line) and type in:

import SimpleHTTPServer  


This will start a small webserver on port 8000 (so you url would be http://localhost:8000) and then you can get to the page that way. I did this with the Beautiful Soup stuff a while ago and it worked liked a champ.