teslariu

server con sockets

Jul 11th, 2022
1,269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # navegador web sencillo con las biblio std
  5.  
  6. import socket
  7.  
  8. conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  9. conn.connect(("google.com",80))
  10. cmd = "GET http://www.google.com/ HTTP/1.0?\r\n\r\n".encode()
  11. conn.send(cmd)
  12.  
  13. while True:
  14.     data = conn.recv(512)
  15.     if len(data) < 1:
  16.         break
  17.     print(data.decode(), end="")
  18.  
  19. conn.close()
  20.  
Advertisement
Add Comment
Please, Sign In to add comment