Python/Sockets
< Python
Sockets
編輯Python可以通過socket通信
連接到伺服器
編輯import socket, sys
sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
sock.connect ( ( "google.com", 80 ) )#網址包含https或http需先去除,http以80port連接,https以ssl這模組+443port連接
sock.send('GET / HTTP/1.1\r\n')
sock.send('User-agent: Mozilla/5.0 (wikibooks test)\r\n\r\n')
print (sock.recv(4096))