Skip to content

Instantly share code, notes, and snippets.

@tjt263
Created March 7, 2016 22:53
Show Gist options
  • Save tjt263/976d3c7aef183fe27cd9 to your computer and use it in GitHub Desktop.
Save tjt263/976d3c7aef183fe27cd9 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import socket
target_host = "www.google.com"
target_port = 80
# create a socket object
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# connect the client
client.connect((target_host, target_port))
# send some data
client.send("GET / HTTP/1.1\r\nHost: google.com\r\n\r\n")
# receive some data
response = client.recv(4096)
print response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment