08/08/30 13:10:03
>>60
前に書いた奴。
クッキーの保持の方法が分からないので2回連続POSTしてるがご愛嬌。
# coding: utf-8
import urllib2, cookielib
from urllib import urlencode
def cnvChar(str, code, code2='utf-8'):
return unicode(str, code2).encode(code)
cj = cookielib.CookieJar()
pd = {'bbs': 'board', 'key': 'key', 'time': '1',
'submit': cnvChar('書き込む','cp932'), 'FROM': cnvChar('名前','cp932'),
'mail': cnvChar('メール','cp932'), 'MESSAGE': cnvChar('内容','cp932'), 'hana': 'mogera'}
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-agent', 'Monazilla/1.00 Python/2.5'),
('Referer', 'URLリンク(host.2ch.net)')]
r = opener.open("URLリンク(host.2ch.net)", urlencode(pd))
r = opener.open("URLリンク(host.2ch.net)", urlencode(pd))
教えて君にはソースを見せるのが一番だね