Ejemplo n.º 1
0
 def get_login_captcha(self, captcha_id, size="m"):
     url = "http://www.douban.com/misc/captcha?size=%s&id=%s" % (size,
                                                                 captcha_id)
     pic_image = utils.get_cache_file("pic")
     if utils.download(url, pic_image):
         self.logdebug("Verify code pic download ok!")
         return raw_input("piz input code > ").strip()
Ejemplo n.º 2
0
 def get_verify_code(self):
     url = 'https://passport.baidu.com/v2/api/?logincheck&'
     data = {
         "callback": "bdPass.api.login._needCodestringCheckCallback",
         "tpl": "mn",
         "charset": "UTF-8",
         "index": 0,
         "username": self.username,
         "time": utils.timestamp()
     }
     data_query = urllib.urlencode(data)
     url = "%s&%s" % (url, data_query)
     req = urllib2.Request(url)
     data = self.opener.open(req).read().strip()
     data = data[data.find("(") + 1:data.rfind(")")]
     data = eval(
         data,
         type('Dummy', (dict, ), dict(__getitem__=lambda s, n: n))())
     codestring = data["codestring"]
     if codestring != "":
         url = "https://passport.baidu.com/cgi-bin/genimage?%s" % codestring
         req = urllib2.Request(url)
         ret_data = self.opener.open(req).read()
         pic_image = utils.get_cache_file("pic")
         with open(pic_image, "wb") as fp:
             fp.write(ret_data)
         self.loginfo("Verify code pic download ok!")
         return raw_input("piz input code > ").strip()
Ejemplo n.º 3
0
 def get_verify_code(self):
     url = 'https://passport.baidu.com/v2/api/?logincheck&'         
     data = {
         "callback" : "bdPass.api.login._needCodestringCheckCallback",
         "tpl" : "mn",
         "charset" : "UTF-8",
         "index" : 0,
         "username" : self.username,
         "time" : utils.timestamp()
         }
     data_query = urllib.urlencode(data)
     url = "%s&%s" % (url, data_query)
     req = urllib2.Request(url)
     data = self.opener.open(req).read().strip()
     data = data[data.find("(") + 1: data.rfind(")")]
     data = eval(data, type('Dummy', (dict,), dict(__getitem__=lambda s,n:n))())
     codestring = data["codestring"]
     if codestring != "":
         url = "https://passport.baidu.com/cgi-bin/genimage?%s" % codestring
         req = urllib2.Request(url)
         ret_data = self.opener.open(req).read()
         pic_image = utils.get_cache_file("pic")
         with open(pic_image, "wb") as fp:
             fp.write(ret_data)
         self.loginfo("Verify code pic download ok!")
         return raw_input("piz input code > ").strip()    
Ejemplo n.º 4
0
    def __init__(self, parent=None):
        super(HistoryModel, self).__init__(parent)
        self._all_data = []
        self._current_page = 1
        self._total_page = 1

        self._db = utils.get_cache_file("history.db")
        self._data = []
        self.load_all_data()
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        super(HistoryModel, self).__init__(parent)
        self._all_data = []
        self._current_page = 1
        self._total_page = 1

        self._db = utils.get_cache_file("history.db")
        self._data = []
        self.load_all_data()
Ejemplo n.º 6
0
 def check_need_vcode(self, tieba_name):
     params = {"rs1": 0, "rs10" : 1, "lm" : self.get_forum_id(tieba_name),
               "word" : tieba_name, "t" : utils.get_random_t()}
     ret = self.api_request("f/user/json_needvcode", extra_data=params)
     try:
         if ret["data"]["need"] == 1:
             vcode_ret = self.api_request(ret["data"]["vcodeUrl"])
             vcodestr = vcode_ret["data"]["vcodestr"]
             url = "http://tieba.baidu.com/cgi-bin/genimg?%s" % vcodestr
             req = urllib2.Request(url)
             ret_data = self.opener.open(req).read()
             pic_image = utils.get_cache_file("vcode")
             with open(pic_image, "wb") as fp:
                 fp.write(ret_data)
             self.loginfo("Verify code pic download ok! save to %s", pic_image)
             return pic_image, vcodestr
     except Exception, e:    
         self.logdebug("Check newTie verify code faild, error: %s", e)
Ejemplo n.º 7
0
 def check_need_vcode(self, tieba_name):
     params = {
         "rs1": 0,
         "rs10": 1,
         "lm": self.get_forum_id(tieba_name),
         "word": tieba_name,
         "t": utils.get_random_t()
     }
     ret = self.api_request("f/user/json_needvcode", extra_data=params)
     try:
         if ret["data"]["need"] == 1:
             vcode_ret = self.api_request(ret["data"]["vcodeUrl"])
             vcodestr = vcode_ret["data"]["vcodestr"]
             url = "http://tieba.baidu.com/cgi-bin/genimg?%s" % vcodestr
             req = urllib2.Request(url)
             ret_data = self.opener.open(req).read()
             pic_image = utils.get_cache_file("vcode")
             with open(pic_image, "wb") as fp:
                 fp.write(ret_data)
             self.loginfo("Verify code pic download ok! save to %s",
                          pic_image)
             return pic_image, vcodestr
     except Exception, e:
         self.logdebug("Check newTie verify code faild, error: %s", e)
Ejemplo n.º 8
0
 def get_login_captcha(self, captcha_id, size="m"):
     url = "http://www.douban.com/misc/captcha?size=%s&id=%s" % (size, captcha_id)
     pic_image = utils.get_cache_file("pic")
     if utils.download(url, pic_image):
         self.logdebug("Verify code pic download ok!")
         return raw_input("piz input code > ").strip()