ソケット
httpのクライアントの例
>>> >>> import socket >>> host = "www.google.co.jp" >>> port = 80 >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> s.connect((host, port)) >>> s.sendall("GET / HTTP/1.0\n\n") >>> print s.recv(65536) HTTP/1.0 302 Found Location: http://www.google.co.jp/ Cache-Control: private Content-Type: text/html; charset=UTF-8 Set-Cookie: PREF=ID=21af6f75a93bcefb:TM=1216891200:LM=1216891200:S=HMZ6GnLbg5m_sOwR; expires=Sat, 24-Jul-2010 09:20:00 ^GMT; path=/; domain=.google.com Date: Thu, 24 Jul 2008 09:20:00 GMT Server: gws Content-Length: 221 Connection: Close^ <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"> <TITLE>302 Moved</TITLE></HEAD><BODY> <H1>302 Moved</H1> The document has moved <A HREF="http://www.google.co.jp/">here</A>. </BODY></HTML> >>> s.recv(65536) '' >>> s.close() >>>
2008年07月24日(木) 18:22:47 Modified by hebi_