diff --git a/http-web-services.html b/http-web-services.html index 17a4d48..1954ca5 100644 --- a/http-web-services.html +++ b/http-web-services.html @@ -59,7 +59,8 @@ mark{display:inline} <id>tag:diveintomark.org,2001-07-29:/</id> <updated>2009-03-27T21:56:07Z</updated> <link rel="alternate" type="text/html" href="http://diveintomark.org/"/> - <-- rest of feed omitted for brevity --> + … +
  1. Downloading anything over HTTP is incredibly easy in Python; in fact, it’s a one-liner. The urllib.request module has a handy urlopen() function that takes the address of the page you want, and returns a file-like object that you can just read() from to get the full contents of the page. It just can’t get any easier.
@@ -341,7 +342,8 @@ class DefaultErrorHandler(urllib2.HTTPDefaultErrorHandler): ① <title mode="escaped">dive into mark</title> <link rel="alternate" type="text/html" href="http://diveintomark.org/"/> - <-- rest of feed omitted for brevity --> + … + >>> request.add_header('If-None-Match', ... firstdatastream.headers.get('ETag')) >>> seconddatastream = opener.open(request) @@ -602,7 +604,8 @@ header: Content-Type: application/atom+xml xml:lang="en"> <title mode="escaped">dive into mark</title> <link rel="alternate" type="text/html" href="http://diveintomark.org/"/> - <-- rest of feed omitted for brevity --> + … + >>> len(data) 15955 @@ -711,7 +714,8 @@ def fetch(source, etag=None, last_modified=None, agent=USER_AGENT): 'status': 301, 'data': '<?xml version="1.0" encoding="iso-8859-1"?> <feed version="0.3" -<-- rest of data omitted for brevity -->'} +… +'} >>> if params['status'] == 301: ... url = params['url'] >>> newparams = openanything.fetch(