Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import sys
- def WGet(hostname, port, urlpath):
- ip = socket.gethostbyname(hostname)
- print "Connecting to address: ", ip
- soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- soc.connect((ip, port))
- request = """GET {} HTTP/1.0
- Host:{}
- """.format(urlpath, hostname)
- soc.send(request.replace("\n", "\r\n"))
- data = soc.recv(4096)
- while data:
- print data
- data = soc.recv(4096)
- def main(argv):
- #WGet("bootstrap.pypa.io", 80, "/get-pip.py")
- WGet("127.0.0.1", 8081, "/")
- if __name__ == '__main__':
- sys.exit(main(sys.argv))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement