mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-25 16:44:43 +00:00
23 lines
576 B
Python
23 lines
576 B
Python
|
|
#!/usr/bin/python
|
||
|
|
# -*- coding: iso-8859-1 -*-
|
||
|
|
"""print contents of an url"""
|
||
|
|
|
||
|
|
import httplib, urlparse, sys
|
||
|
|
|
||
|
|
def main (url):
|
||
|
|
parts = urlparse.urlsplit(url)
|
||
|
|
host = parts[1]
|
||
|
|
path = urlparse.urlunsplit(('', '', parts[2], parts[3], parts[4]))
|
||
|
|
h = httplib.HTTPConnection(host)
|
||
|
|
h.connect()
|
||
|
|
h.putrequest("GET", path, skip_host=True)
|
||
|
|
h.putheader("Host", host)
|
||
|
|
h.putheader("Accept-Encoding", "gzip;q=1.0, deflate;q=0.9, identity;q=0.5")
|
||
|
|
h.endheaders()
|
||
|
|
req = h.getresponse()
|
||
|
|
print req.read()
|
||
|
|
|
||
|
|
|
||
|
|
if __name__=='__main__':
|
||
|
|
main(sys.argv[1])
|