import urllib
import urllib2
import cookielib
req = urllib2.Request(
'
http://pc11.2ch.net/test/bbs.cgi',
urllib.urlencode(
{
'bbs' : 'tech',
'key' : '1226830195',
'time' : 1,
'submit' : u'書き込み'.encode('sjis'),
'FROM' : '',
'mail' : 'sage',
'MESSAGE' : u'おっぱい'.encode('sjis'),
'suka' : 'pontan'
}
),
{'Referer' : '
http://pc11.2ch.net/'}
)
opener = urllib2.build_opener(
urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
res1 = opener.open(req)
if '<!-- 2ch_X:cookie -->' in res1.read():
res2 = opener.open(req)