download x bytes at a time over network

Saurabh phonethics at gmail.com
Tue Mar 17 02:45:23 EDT 2009


> This isn't exactly how things work.  The server *sends* you bytes.  It can
> send you a lot at once.  To some extent you can control how much it sends
> before it waits for you to catch up, but you don't have anywhere near
> byte-level control (you might have something like 32kb or 64kb level
> control).

What abt in Python3 ?
It seems to have some header like the one below : b'b495 - binary mode
with 46229 bytes ? Or is it something else ?

>>> import urllib.request
>>> url = "http://feeds2.feedburner.com/jquery/"
>>> handler = urllib.request.urlopen(url)
>>> data = handler.read(1000)
>>> print("""Content :\n%s \n%s \n%s""" % ('=' * 100, data, '=' * 100))
Content :
====================================================================================================
b'b495\r\n<?xml version="1.0" encoding="UTF-8"?>\r\n<?xml-stylesheet
type="text/xsl" media="screen"
href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css"
media="screen" href="http://feeds2.feedburner.com/~d/styles/itemcontent.css"?><!--
generator="wordpress/2.0.11" --><rss
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
version="2.0">\r\n\r\n<channel>\r\n\t<title>jQuery
Blog</title>\r\n\t<link>http://blog.jquery.com</link>\r\n\t<description>New
Wave Javascript.</description>\r\n\t<pubDate>Fri, 13 Mar 2009 13:07:07
+0000</pubDate>\r\n\t<generator>http://wordpress.org/?v=2.0.11</generator>\r\n\t<language>en</language>\r\n\t\t\t<atom10:link
xmlns:atom10="http://www.w3.org/2005/Atom" rel="self"
href="http://feeds2.feedburner.com/jquery" type="application/rss+xml"
/><item>\r\n\t\t<title>This Week in jQuery, vol.
1</title>\r\n\t\t<link>http://blog.jquery.com/2009/03/13/this-week-in-jquery-vol-1/</link>\r\n\t\t<comments>http:'
====================================================================================================
>>>



More information about the Python-list mailing list