Exemplo n.º 1
0
def capture_main_data():
    print(sys.path)
    sp = QQZoneSpider(use_redis=True, debug=True, download_small_image=False, download_big_image=False)
    sp.login_with_qr_code()
    sp.get_main_page_info()
    sp.get_mood_list()
    sp.user_info.save_user(sp.username)
Exemplo n.º 2
0
def get_user_basic_info():
    sp = QQZoneSpider(use_redis=True, debug=False, mood_begin=0, mood_num=-1,
                      stop_time='2015-06-01',
                      download_small_image=False, download_big_image=False,
                      download_mood_detail=True, download_like_detail=True,
                      download_like_names=True, recover=False, cookie_text=None)
    return sp.user_info
Exemplo n.º 3
0
 def test_step(self):
     sp = QQZoneSpider(use_redis=False, debug=False)
     step1 = sp.find_best_step(1100, 5)
     step2 = sp.find_best_step(1222, 5)
     step3 = sp.find_best_step(2222, 10)
     assert step1 == 220
     assert step2 == 240
     assert step3 == 220
Exemplo n.º 4
0
def capture_main_data():
    sp = QQZoneSpider(use_redis=True,
                      debug=False,
                      download_small_image=False,
                      download_big_image=False)
    sp.login()
    sp.get_main_page_info()
    sp.get_mood_list()
    sp.user_info.save_user(sp.username)
Exemplo n.º 5
0
    def test_capture_info(self):
        sp = QQZoneSpider(use_redis=True,
                          debug=False,
                          mood_num=20,
                          download_mood_detail=False,
                          download_like_detail=True,
                          download_like_names=False)

        sp.login()
        sp.get_mood_list()
Exemplo n.º 6
0
 def test_download_image(self):
     sp = QQZoneSpider(use_redis=False,
                       debug=False,
                       mood_num=100,
                       download_mood_detail=False,
                       download_like_detail=False,
                       download_like_names=False,
                       download_big_image=True,
                       download_small_image=True)
     sp.login()
     sp.get_mood_list()
     print("Thread Wait:", sp.image_thread_pool.time_spend)
Exemplo n.º 7
0
def test_step():
    sp = QQZoneSpider(use_redis=True,
                      debug=True,
                      mood_begin=0,
                      mood_num=1000,
                      stop_time='-1',
                      download_small_image=False,
                      download_big_image=False,
                      download_mood_detail=True,
                      download_like_detail=True,
                      download_like_names=True,
                      recover=False,
                      cookie_text=None)
    sp.find_best_step(1100, 5)
    sp.find_best_step(1222, 5)
    sp.find_best_step(2222, 10)
Exemplo n.º 8
0
    def test_extract_tid(self):
        sp = QQZoneSpider(use_redis=False,
                          debug=False,
                          mood_num=20,
                          download_mood_detail=False,
                          download_like_detail=True,
                          download_like_names=False)
        str1 = 'http://user.qzone.qq.com/1272082503/mood/4770d24b00acd95c13e00500.1<.>http://user.qzone.qq.com/1272082503/mood/4770d24b00acd95c13e00500.1'
        str2 = 'http://user.qzone.qq.com/1272082503/mood/4770d24bbb83d95c05600900.1^||^https://b339.photo.store.qq.com/psb?/91b7c939-e3c7-41d8-a450-626a11d7ce19/4iKMKW.M8phXT8bghzPgKjz.rdkmby5vOiOJi4PqSlk!/b/dFMBAAAAAAAA&bo=7gI2Be4CNgURECc!^||^0'
        str3 = 'http://user.qzone.qq.com/1272082503/mood/4770d24b5c91d65cf9af0b00.1<.>http://user.qzone.qq.com/1272082503/mood/4770d24b5c91d65cf9af0b00.1'
        expect1 = '4770d24b00acd95c13e00500'
        expect2 = '4770d24bbb83d95c05600900'
        expect3 = '4770d24b5c91d65cf9af0b00'

        assert expect1 == sp.extract_tid_from_unikey(str1)
        assert expect2 == sp.extract_tid_from_unikey(str2)
        assert expect3 == sp.extract_tid_from_unikey(str3)
Exemplo n.º 9
0
def capture_data():
    sp = QQZoneSpider(use_redis=True,
                      debug=True,
                      mood_begin=0,
                      mood_num=-1,
                      stop_time='-1',
                      download_small_image=False,
                      download_big_image=False,
                      download_mood_detail=True,
                      download_like_detail=True,
                      download_like_names=True,
                      recover=False,
                      cookie_text=None)
    sp.login()
    sp.get_main_page_info()
    sp.get_mood_list()
    sp.user_info.save_user(sp.username)
Exemplo n.º 10
0
 def test_get_main_page(self):
     sp = QQZoneSpider(use_redis=False, debug=True)
     sp.login()
     sp.get_main_page_info()
Exemplo n.º 11
0
 def test_selenium_login(self):
     sp = QQZoneSpider(use_redis=False, debug=False)
     sp.login()
Exemplo n.º 12
0
 def test_simple_qr_login(self):
     sp = QQZoneSpider(use_redis=False, debug=True, mood_num=200)
     sp.login_with_qr_code()
Exemplo n.º 13
0
    def __init__(self):
        self.sp = QQZoneSpider(use_redis=False,
                               debug=False,
                               from_client=True,
                               mood_num=20)
        warm_tip = "****************************************\n" \
                   "**************QQ空间抽奖小程序***************\n" \
                   "****************************************"
        self.output(warm_tip)
        self.output("请输入获取最近访客的时间间隔,默认为60秒")
        time_step = input()
        try:
            time_step = int(time_step)
        except:
            time_step = 60
        visit_file_name = "最近访客" + get_full_time_from_mktime(int(
            time.time())) + ".xlsx"
        self.output("最近访客文件名:" + visit_file_name)

        try:
            self.sp.login_with_qr_code()
            self.output("用户" + self.sp.username + "登陆成功!")
        except BaseException:
            self.output("用户登陆失败!请检查网络连接或稍后再试!")
            exit(1)

        visit_t = threading.Thread(target=self.sp.parse_recent_visit,
                                   args=[visit_file_name, time_step])
        visit_t.start()
        self.output("正在获取最近的说说...")
        url_mood = self.sp.get_mood_url()
        url_mood = url_mood + '&uin=' + str(self.sp.username)
        self.content_list = self.get_content_list(url_mood, 0)
        self.content_list += self.get_content_list(url_mood, 20)
        self.content_list += self.get_content_list(url_mood, 40)
        self.output('------------------------')
        self.output("最近的60条说说:")
        for item in self.content_list:
            content = item['content']
            if len(content) > 20:
                content = content[0:20] + '。。。'
            item_str = '|' + str(item['order']) + '|' + content
            self.output(item_str)
        while True:
            try:
                self.output('------------------------')
                self.output("**以下输入请全部只输入数字!按回车键结束输入!**")
                self.output("**输入Q退出本程序**")
                is_digit = False
                while not is_digit:
                    self.output('请输入您要选择的说说序号:')
                    mood_order = input()
                    is_digit = self.check_input(mood_order)
                mood_order = int(mood_order)
                if mood_order > len(self.content_list):
                    pos = (math.ceil(mood_order / 20) - 1) * 20
                    mood_order = mood_order % 20
                    t1 = threading.Thread(target=self.get_all,
                                          args=(url_mood, pos, mood_order))
                    t1.setDaemon(True)
                    t1.start()
                else:
                    unikey = self.content_list[mood_order - 1]
                    key = unikey['unikey']
                    tid = unikey['tid']
                    t2 = threading.Thread(target=self.start_like_cmt_thread,
                                          args=(key, tid))
                    t2.setDaemon(True)
                    t2.start()
                is_digit = False
                while not is_digit:
                    self.output('请输入抽奖的类型,1-点赞;2-评论;(其它)-我全都要! :')
                    type = input()
                    is_digit = self.check_input(type)
                is_digit = False
                while not is_digit:
                    self.output('请选择抽奖的用户数量:')
                    user_num = input()
                    is_digit = self.check_input(user_num)
                # 等待线程运行完
                try:
                    t1.join()
                    t2.join()
                    self.like_t.join()
                    self.cmt_t.join()
                except:
                    pass
                self.type = int(type)
                self.user_num = int(user_num)
                self.file_name = self.content_list[mood_order - 1]['content']
                if len(self.file_name) > 10:
                    self.file_name = self.file_name[:10]
                self.file_name = re.sub('[^\w\u4e00-\u9fff]+', '',
                                        self.file_name)
                if len(self.file_name) <= 0:
                    self.file_name = str(mood_order)
                print("说说:", self.file_name)
                self.do_raffle()
                cmt_df = pd.DataFrame(self.cmt_list)
                like_df = pd.DataFrame(self.like_list)
                cmt_df.to_excel("评论-" + self.file_name + '.xlsx', index=False)
                like_df.to_excel("点赞-" + self.file_name + '.xlsx', index=False)
            except BaseException as e:
                if str(e) == '2':
                    exit(2)
                else:
                    self.output('----------------------')
                    print(e)
                    self.output("未知错误,请重新尝试")
                    self.output('----------------------')
Exemplo n.º 14
0
 def test_get_first_mood(self):
     sp = QQZoneSpider(use_redis=False, debug=True)
     sp.login_with_qr_code()
     mood_num = sp.get_mood_num()
     sp.get_first_mood(mood_num)
Exemplo n.º 15
0
 def test_capture_info_parallel(self):
     sp = QQZoneSpider(use_redis=True, debug=False, mood_num=200)
     sp.login()
     sp.get_mood_list()
Exemplo n.º 16
0
 def test_login_with_qr_code(self):
     sp = QQZoneSpider(use_redis=True, debug=True, mood_num=200)
     sp.login_with_qr_code()
     print("Login success")
     sp.get_main_page_info()
     sp.get_mood_list()
Exemplo n.º 17
0
 def test_capture_main_data(self):
     sp = QQZoneSpider(use_redis=True, debug=False)
     sp.login()
     sp.get_main_page_info()
     sp.get_mood_list()
Exemplo n.º 18
0
 def test_login_with_qr_code(self):
     sp = QQZoneSpider(use_redis=True, debug=True)
     sp.login_with_qr_code()