Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

GET Stream From The Web Using Python

DZone's Guide to

GET Stream From The Web Using Python

·
Free Resource
GETs files from a remote webserver. I'm using it for streaming

def get(host,port,url):
    h = httplib.HTTP(host, port)
    h.putrequest('GET', url)
    h.putheader('Host', host)
    h.putheader('User-agent', 'python-httplib')
    h.endheaders()

    (returncode, returnmsg, headers) = h.getreply()
    if returncode != 200:
        print returncode, returnmsg
        sys.exit()

    f = h.getfile()
    return f.read()
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}