import re
import copy
+import time
from bbs_type_exception import BbsTypeError
return "http://" + self.host + "/test/read.cgi/" + \
self.board + "/" + self.thread + "/"
+ def get_post_uri(self):
+ return "http://" + self.host + "/test/bbs.cgi"
+
+ def build_post_dict(self, name, mail, msg):
+ post_dict = {}
+ post_dict["bbs"] = self.board
+ post_dict["key"] = self.thread
+ post_dict["time"] = str(int(time.time()))
+ post_dict["submit"] = u"\u66f8\u304d\u8fbc\u3080".encode(
+ "cp932", "replace")
+ post_dict["FROM"] = name.encode("cp932", "replace")
+ post_dict["mail"] = mail.encode("cp932", "replace")
+ post_dict["MESSAGE"] = msg.encode("cp932", "replace")
+ return post_dict
+
def set_extra_post(self, post_dict):
return post_dict
import urllib2
import cookielib
import os.path
-import time
from BbsType import bbs_type_judge_uri
from BbsType import bbs_type_exception
self.entry_mail = self.widget_tree.get_widget("entry_mail")
self.textbuffer = self.widget_tree.get_widget("textview").get_buffer()
- self.post_dict = {}
- self.post_dict["bbs"] = self.bbs_type.board
- self.post_dict["key"] = self.bbs_type.thread
- self.post_dict["time"] = str(int(time.time()))
- self.post_dict["submit"] = u"\u66f8\u304d\u8fbc\u3080".encode(
- "cp932", "replace")
-
sigdic = {"on_submit_activate": self.on_submit_activate,
"on_close_activate": self.on_close_activate}
msg = self.textbuffer.get_text(
self.textbuffer.get_start_iter(), self.textbuffer.get_end_iter())
- self.post_dict["FROM"] = name.encode("cp932", "replace")
- self.post_dict["mail"] = mail.encode("cp932", "replace")
- self.post_dict["MESSAGE"] = msg.encode("cp932", "replace")
-
+ self.post_dict = self.bbs_type.build_post_dict(name, mail, msg)
self.post_dict = self.bbs_type.set_extra_post(self.post_dict)
self.do_submit()
post_encoded = urllib.urlencode(self.post_dict)
print post_encoded
- req = urllib2.Request("http://" + self.bbs_type.host + "/test/bbs.cgi",
- post_encoded)
+ req = urllib2.Request(self.bbs_type.get_post_uri(), post_encoded)
req.add_header("Referer", self.uri)
res = opener.open(req)