笔记:QQ空间秒赞

JS秒赞  按F12  进入控制台  粘贴 回车

var x = 5, y = 5;
window.setInterval(function(){
    y = y + 5;
    var zan = document.getElementsByClassName('item qz_like_btn_v3');
    for (var i = 0; i < zan.length; i++) {
        if (zan[i].attributes[6].value == 'like') {
            zan[i].firstChild.click();
        }
    };
    window.scrollBy(x, y);
}, 2000);


window.setInterval(function(){

	window.scrollTo(0,0);
	document.getElementById('feed_friend_refresh').firstChild.click();

}, 60000);

Pythone QQ空间秒赞  python-3.8.8 环境

pip install selenium==3.141.0

pip install xlrd==1.2.0

#encoding=utf-8

import xlrd
import random

import time,os,json
import re
import demjson
import urllib
import requests
import _thread as thread

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

def log(content):
    this_time = time.strftime('%H:%M:%S',time.localtime(time.time()))
    print("["+str(this_time)+"]" + content)


class QQ_like:

    def __init__(self,cell0,cell1):
        self.qq_number = cell0
        self.password = cell1

        self.keylist = ["0","1","2"]

        self.cookie_dict_txt = self.qq_number + '_cookie_dict.txt'

        self.headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'}
        self.get_preparameter()
        self.run_tolike()
    def get_preparameter(self):
        self.search_cookie()
        self.get_g_tk()
        self.get_space()
    def run_tolike(self):
        # 登录成功后 死循环进行点赞
        while True:
            #  如果是指定捕获的异常不退出循环
            try:
                self.get_friends_list()
            except KeyError as ke:
                log('捕获KeyError异常')
            except urllib.exceptions.ReadTimeoutError as uer:
                log('ReadTimeoutError异常')
            except requests.ConnectTimeout as rc:
                log('ConnectTimeout异常')
            time.sleep(__import__('random').randint(3,10))
    def search_cookie(self):
        if not os.path.exists(self.cookie_dict_txt):
            self.get_cookie_json()
        with open(self.cookie_dict_txt, 'r') as f:
            self.cookie=json.load(f)
        return True
    def get_cookie_json(self):
        login_url = 'https://i.qq.com/'
        chrome_options =Options()
        chrome_options.add_argument('--headless')
        # linux 解决 添加这句即可
        chrome_options.add_argument('--no-sandbox')
        driver = webdriver.Chrome(options=chrome_options)
        driver.get(login_url)
        driver.implicitly_wait(30)
        # 二维码下载
        r = requests.get('https://ssl.ptlogin2.qq.com/ptqrshow?appid=549000912&e=2&l=M&s=3&d=72&v=4&t=0.{0}6252926{1}2285{2}86&daid=5'.format(random.randint(0,9),random.randint(0,9),random.randint(0,9)),stream=True)
        with open('./'+self.qq_number+'_v.png', 'wb') as f:
            f.write(r.content)

        driver.switch_to_frame('login_frame')
        driver.find_element_by_xpath('//*[@id="switcher_plogin"]').click()
        time.sleep(1)
        driver.find_element_by_xpath('//*[@id="u"]').send_keys(self.qq_number)
        driver.find_element_by_xpath('//*[@id="p"]').send_keys(self.password)
        time.sleep(1)
        driver.find_element_by_xpath('//*[@id="login_button"]').click()
        time.sleep(1)
        cookie_list = driver.get_cookies()
        cookie_dict = {}
        for cookie in cookie_list:
            if 'name' in cookie and 'value' in cookie:
                cookie_dict[cookie['name']] = cookie['value']
        with open(self.cookie_dict_txt , 'w') as f:
            json.dump(cookie_dict, f)
        return True
    def get_g_tk(self):
        p_skey = self.cookie['p_skey']
        h = 5381
        for i in p_skey:
            h += (h << 5) + ord(i)
            self.g_tk = h & 2147483647
    def get_space(self):
        your_url = 'https://user.qzone.qq.com/' + str(self.qq_number)
        html = requests.get(your_url,headers=self.headers,cookies=self.cookie, timeout=5)
        if html.status_code == 200:
            self.qzonetoken = re.findall('window.g_qzonetoken =(.*?);',html.text,re.S)[0].split('"')
        return True
    def get_friends_list(self):
        times = ""
        url = "https://user.qzone.qq.com/proxy/domain/ic2.qzone.qq.com/cgi-bin/feeds/feeds3_html_more?"
        data = {
            'uin': self.qq_number,
            'scope': '0',
            'view': '1',
            'daylist': '',
            'uinlist': '',
            'gid': '',
            'flag': '1',
            'filter':'all',
            'applist': 'all',
            'refresh': '0',
            'aisortEndTime': '0',
            'aisortOffset': '0',
            'getAisort': '0',
            'aisortBeginTime': '0',
            'pagenum': '1',
            'externparam': 'undefined',
            'firstGetGroup': '0',
            'icServerTime': '0',
            'mixnocache': '0',
            'scene': '0',
            'begintime': 'undefined',
            'count': '10',
            'dayspac': 'undefined',
            'sidomain': 'qzonestyle.gtimg.cn',
            'useutf8': '1',
            'outputhtmlfeed': '1',
            'rd': '0.9311604844249088',
            'usertime': str(round(time.time() * 1000)),
            'windowId': '0.51158950324406',
            'g_tk': self.g_tk,
            'qzonetoken': self.qzonetoken,
        }
        url = url + urllib.parse.urlencode(data) + '&g_tk=' + str(self.g_tk)
        html = requests.get(url,headers=self.headers,cookies=self.cookie, timeout=5)
        if html.status_code == 200:
            text = html.text[10:-2].replace(" ", "").replace('\n','')
            json_list = demjson.decode(text)['data']['data']

            keylist = ["0","1","2"]
            for num in range(0,3):
                print (num)

                qq_spaces = json_list[num]
                content = str(qq_spaces['html'])

                try:zanshu = re.findall('<spanclass="f-like-cnt">(.*?)</span>人觉得很赞</div>',content,re.S)[0]
                except:zanshu = '0'
                try:people = re.findall('"visitor">浏览(.*?)</a>',content,re.S)[0]
                except:people = '0'
                try:txt = str(re.findall('"f-info">(.*?)<',content,re.S))
                except:txt = '0'
                log("说说 " + str(num) + " : 名字:" + str(qq_spaces['nickname']) + " QQ号:"+str(qq_spaces['opuin']) + " 时间:"+str(qq_spaces['feedstime']) + " 赞数:" +zanshu + " 浏览次数:" + people + " 说说内容:"+txt)

                his_url = re.findall('data-curkey="(.*?)"',content ,re.S)[0]
                keylist[num] = str(qq_spaces['key'])
                if keylist[num] not in self.keylist :
                    self.get_zan(times,his_url)
                else:log("说说"+str(num)+"无更新 等待中")

            self.keylist = keylist
        # 异常错误
        else:log(html.status_code)
    def get_zan(self,times,his_url):
        data = {'g_tk': self.g_tk,'qzonetoken': self.qzonetoken}
        post_data = {
            'qzreferrer': 'https://user.qzone.qq.com/'+str(self.qq_number),
            'opuin': str(self.qq_number),
            'unikey': str(his_url),
            'curkey': str(his_url),
            'from': '1',
            'appid': '311',
            'typeid': '0',
            'abstime': str(times),
            'fid': str(his_url).split('/')[-1],
            'active': '0',
            'fupdate': '1'
        }
        url = 'https://user.qzone.qq.com/proxy/domain/w.qzone.qq.com/cgi-bin/likes/internal_dolike_app?'
        url = url + urllib.parse.urlencode(data)
        html = requests.post(url,headers=self.headers,cookies=self.cookie,data=post_data, timeout=5)
        if html.status_code == 200:log("点赞成功" if len(html.text) == 469 else "点赞失败")
        else:
            log('点赞失败')

def print_time( cell0, cell1):
    QQ_like(cell0,cell1)
    while True:
        try:
            QQ_like(cell0,cell1)
        except Exception as e:
            if os.path.exists( cell0 + '_cookie_dict.txt' ):
                os.remove(cell0 + '_cookie_dict.txt')
            log("出现了登录异常 10分钟后 重新登录")

        time.sleep(600)


if __name__ == '__main__':
    # 这里读取excel 如果不需要 可直接 start_new_thread 传账号密码即可
    sheet = xlrd.open_workbook('user.xlsx').sheet_by_index(0)
    for num in range(1,sheet.nrows):
        cell0 = sheet.cell(num,0)
        cell1 = sheet.cell(num,1)
        thread.start_new_thread(print_time(cell0.value,cell1.value ))



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值