#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2008 Doug Hellmann All rights reserved. # """Simple example with urllib2.urlopen(). """ #end_pymotw_header import urllib2 request = urllib2.Request('http://localhost:8080/') request.add_header('User-agent', 'PyMOTW (http://www.doughellmann.com/PyMOTW/)') response = urllib2.urlopen(request) data = response.read() print data