예제 #1
0
 def reply_status(self, response):
     #重新返回首页,对特别是需要回复的模块特别有用,而不需要回复的帖子缺对性能是个损失.
     #查询回复状态
     
     success = u'非常感谢,你的回复已经发布'.encode('gbk', 'ignore')
     status = re.findall(success, response.body)
     username_sql = sql.select_accountbyusername(self.username, self.platform)
     
     #回复数量限制
     failture = u'对不起,您所在的用户组每小时限制发帖 '.encode('gbk', 'ignore')
     failture_status = re.findall(failture, response.body, re.I)
     if failture_status:
         return
     if status:
         log.msg('reply success', log.INFO) 
         reply_nums = handle_db(username_sql)['data'][0]
         self.point_num = reply_nums[5]
         self.reply_num = reply_nums[-2]
         self.reply_num += 1
         self.point_num += 1
         #回复成功.账号reply_num+1,积分+1
         try:
             update_replynum = sql.update_account_username(self.username, self.platform, self.reply_num, self.point_num)
             update_success = handle_db(update_replynum)
             log.msg(('<username: %s \'s integral is : +1 ,now integral is %s>' % (self.username, self.reply_num)), log.INFO)
         except Exception, e:
             log.msg(str(traceback.print_exc()), log.ERROR)
예제 #2
0
    def get_apk(self, response):

        filename = ''.join([str(random.randrange(1,100000)), '.apk'])
#        if os.path.exists(''.join([os.getcwd(), os.sep, 'gfan', os.sep, 'download', os.sep, time.strftime('%Y-%m-%d'),os.sep])) is False:
#            os.mkdir(''.join([os.getcwd(), os.sep, 'gfan', os.sep, 'download', os.sep, time.strftime('%Y-%m-%d'),os.sep]))
        #调用新建文件夹的方法
        down_dir = utils.make_spiderdir(self.platform, 'download')
        #解码:有的文件可能是utf-8编码,解为unicode
        try:
            filename = filename.decode('utf-8', 'ignore')
        except:
            pass
        filename = ''.join([down_dir, os.sep, str(time.time()).split('.')[0], filename])
        open(filename, 'wb').write(response.body)
        #下载后在存数据库,确保准确性
        topic_url = response.request.meta['topic_url']
        hashurl = sql.hash_topic(topic_url)
        updatedate = time.strftime('%Y-%m-%d %H:%M:%S')
        filename = filename.replace('\\', '\\\\')
        insert_sql = sql.insert_softwareinfo(self.platform, hashurl, topic_url, updatedate, filename)
        status = handle_db(insert_sql)
        log.msg(str(status), log.DEBUG) 
        #更新topic数据库表
        update_topic_url = sql.topicurl_withcrawed(topic_url)
        status = handle_db(update_topic_url)
        log.msg(str(status), log.DEBUG)

        #能进入本方法执行,表示已经下载了该response.积分-1
        account_sql = sql.select_accountbyusername(self.username, self.platform)
        point_num = handle_db(account_sql)['data'][0][5]
        point_num -= 1
        #然后执行更新
        update_account_pointsql = sql.update_account_point(self.username, self.platform, point_num)
        n = handle_db(update_account_pointsql)
        if n['errorNo'] == 0:
            log.msg(('<username: %s \'s integral is : -1 ,now integral is %s>' % (self.username, self.reply_num)), log.INFO)
        try:
            autocopy.copy(filename, self.platform)
            log.msg('copy job is successed', log.INFO)
        except:
            log.msg(str(traceback.print_exc()), log.ERROR)
            log.msg('copy job is failture', log.ERROR)
        
        request_topic = self.repeat_reply(response)
        return request_topic
예제 #3
0
 def reply_status(self, response):
     #重新返回首页,对特别是需要回复的模块特别有用,而不需要回复的帖子缺对性能是个损失.
     #查询回复状态
     
     success = u'非常感谢,你的回复已经发布'.encode('gbk', 'ignore')
     status = re.findall(success, response.body)
     username_sql = sql.select_accountbyusername(self.username, self.platform)
     print 'status', status
             #回复数量限制
     failture = u'对不起,您所在的用户组每小时限制发帖 '.encode('gbk', 'ignore')
     failture_status = re.findall(failture, response.body, re.I)
     if failture_status:
         print u'对不起,您所在的用户组每小时限制发帖 '
         return
     
     if status:
         log.msg('reply success', log.INFO) 
         reply_nums = handle_db(username_sql)['data'][0]
         self.point_num = reply_nums[5]
         self.reply_num = reply_nums[-2]
         self.reply_num += 1
         self.point_num += 1
         #回复成功.账号reply_num+1,积分+1
         try:
             update_replynum = sql.update_account_username(self.username, self.platform, self.reply_num, self.point_num)
             update_success = handle_db(update_replynum)
             log.msg(('<username: %s \'s integral is : +1 ,now integral is %s>' % (self.username, self.reply_num)), log.INFO)
             #回复成功,执行下载
             url = response.request.meta['topic_url']
             print u'回复成功主题:url---->', url
             #回复成功,重新进入topic页
             self.topic_reply_num -= 1
             log.msg(('reply success, will download software%s' % str(self.topic_reply_num)), log.DEBUG)
             log.msg(str(response), log.DEBUG)
             request = self.get_down_topic(response, url)
             return request
         except Exception, e:
             log.msg(str(traceback.print_exc()), log.ERROR)
             #重调get_topic.同时REPLY_NUM-1,当REPLY_NUM<1时,不在做任何事情.
             self.topic_reply_num -= 1
             log.msg(('reply success, will download software', str(self.topic_reply_num)), log.DEBUG)
             log.msg(str(response), log.DEBUG)
             request_topic = self.repeat_reply(response)
             return request_topic
예제 #4
0
 def reply_status(self, response):
     #重新返回首页,对特别是需要回复的模块特别有用,而不需要回复的帖子缺对性能是个损失.
     #查询回复状态
     
     success = '非常感谢,您的回复已经发布'
     status = re.findall(success, response.body)
     username_sql = sql.select_accountbyusername(self.username, self.platform)
     
     if status:
         log.msg('reply success', log.INFO) 
         reply_nums = handle_db(username_sql)['data'][0]
         self.point_num = reply_nums[5]
         self.reply_num = reply_nums[-2]
         self.reply_num += 1
         self.point_num += 1
         #回复成功.账号reply_num+1,积分+1
         try:
             update_replynum = sql.update_account_username(self.username, self.platform, self.reply_num, self.point_num)
             update_success = handle_db(update_replynum)
             log.msg(('<username: %s \'s integral is : +1 ,now integral is %s>' % (self.username, self.reply_num)), log.INFO)
         except Exception, e:
             log.msg(str(traceback.print_exc()), log.ERROR)
예제 #5
0
 def reply_status(self, response):
     #重新返回首页,对特别是需要回复的模块特别有用,而不需要回复的帖子缺对性能是个损失.
     #查询回复状态
     
     success = '非常感谢,您的回复已经发布'
     status = re.findall(success, response.body)
     print self.username
     username_sql = sql.select_accountbyusername(self.username, self.platform)
     
     if status:
         print 'reply success'
         reply_nums = handle_db(username_sql)['data'][0]
         
         self.reply_num = reply_nums[-2]
         self.reply_num += 1
         #回复成功.账号reply_num+1
         try:
             now_time = time.strftime('%Y-%m-%d %H:%M:%S')
             update_replynum = sql.update_account_username(self.username, now_time, self.platform, self.reply_num)
             update_success = handle_db(update_replynum)
             print update_success
             print 'update success! user\'s reply_num + 1'
         except Exception, e:
             traceback.print_exc()