1. Home
  2. Computing & Technology
  3. Python

Building a Web Client in Python

From , former About.com Guide

8 of 9

Printing the Web Page With Python

Now, all of the data is contained within buff. All we need to do is step through it, printing as we go.

for line in buff:      print line

Now, you can save the program and call it with the name of the server and the name of the file you want to see. For example, try:

python simple_web_client.py python.about.com /

If you run your own server, you can access your web directory as follows:

python simple_web_client.py localhost /
What you will receive is the raw HTML of the index file. You can then process it as plain text or parse it with urllib or urllib2.

Explore Python
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Python
  4. Networking
  5. Python Web Client Programming : Printing the Web Page With Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.