python實現QQ空間自動點贊功能
阿新 • • 發佈:2021-06-22
專案
使用python實現qq空間自動點贊功能。
需自行安裝庫並配置環境。
程式執行方法:將程式碼存為.py檔案,執行即可。
輸入QQ密碼的時候採用了linux登入的方式――沒有回顯。
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
import requests
import demjson
import re
import datetime
import getpass
qq = ''
pwd = ''
def print_time():
print(datetime.datetime.now(), end=' ')
def get_gtk(p_skey):
hash=5381
for i in p_skey:
hash += (hash << 5)+ord(i)
print_time()
print('生成gtk')
return hash & 0x7fffffff
def change_cookie(cookie):
s = ''
for c in cookie:
s = s + c['name'] + '=' + c['value'] + '; '
return s
def check_time():
now = datetime.datetime.now()
hour = str(now)[11:13]
minute = str(now)[14:16]
second = str(now)[17:19]
if 0 == int(hour) % 6 and minute == '00' and int(second) < 30:
return True
else:
return False
def get_cookie():
chrome_options = Options()
chrome_options.add_argument('--headless')
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('https://qzone.qq.com/')
driver.switch_to.frame('login_frame')
driver.find_element_by_id('switcher_plogin').click()
driver.find_element_by_id('u').clear()
driver.find_element_by_id('u').send_keys(qq)
driver.find_element_by_id('p').clear()
driver.find_element_by_id('p').send_keys(pwd)
driver.find_element_by_id('login_button').click()
time.sleep(1)
driver.find_element_by_id(