リンク
ちゃんと調べるときは
http://www.python.jp/doc/release/
Wiki内検索
最近更新したページ
最新コメント
文字コードの判定 by awesome things!
正規表現 by awesome things!
辞書 by stunning seo guys
文字列の16進変換 by check it out
文字コードの変換 by check this out
デバッガ by check this out
サブプロセス by watch for this
文字コードの判定 by watch for this
サニタイジング by check this out
タグ

ソケット

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_




スマートフォン版で見る