模擬登錄QQ空間
阿新 • • 發佈:2018-05-30
__main__ TP webdriver spider tab IT num asc tps
# coding=utf-8
from selenium import webdriver
# 模擬登錄QQ空間
def Start_Login():
# 這個是chormedriver的地址
driver = webdriver.Chrome(executable_path=‘K:\\python-workspace\\QQSpider-master\\QQSpider1\\chromedriver.exe‘)
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(‘qqnum‘) #這裏填寫你的QQ號
driver.find_element_by_id(‘p‘).clear()
driver.find_element_by_id(‘p‘).send_keys(‘qqpwd‘) #這裏填寫你的QQ密碼
driver.find_element_by_id(‘login_button‘).click()
driver.find_element_by_id(‘dialog_button_1‘).click()
# 這個函數用來解決騰訊g_tk加密算法的函數
def get_g_tk(cookie):
hashes = 5381
for letter in cookie[‘p_skey‘]:
hashes += (hashes << 5) + ord(letter) # ord()是用來返回字符的ascii碼
return hashes & 0x7fffffff
if __name__ == ‘__main__‘:
Start_Login()
模擬登錄QQ空間