add kktix auto sign-in sign-out

master
Your Name 2024-03-27 10:12:52 +08:00
parent 60f83872ed
commit 4ca9e4f066
2 changed files with 25 additions and 15 deletions

View File

@ -117,31 +117,41 @@ async def kktix_signin_nodriver(kktix_account, kktix_password):
driver = await uc.start() driver = await uc.start()
profile_url = "https://kktix.com/users/edit" profile_url = "https://kktix.com/users/edit"
signin_url = "https://kktix.com/users/sign_in" signin_url = "https://kktix.com/users/sign_in"
signout_url = "https://kktix.com/users/sign_out" #signout_url = "https://kktix.com/users/sign_out"
while True: while True:
try: try:
tab = await driver.get(signin_url) tab = await driver.get(signin_url)
#html = await tab.get_content() #html = await tab.get_content()
#await tab.sleep(0.1) #await tab.sleep(0.1)
#print(html) #print(html)
account = await tab.select("#user_login")
await account.send_keys(kktix_account)
#await tab.sleep(0.1)
password = await tab.select("#user_password") x = await tab.js_dumps('window')
await password.send_keys(kktix_password) #print(x)
#await tab.sleep(0.1) #print(x["location"]["href"])
if x["location"]["href"]=="signin_url":
account = await tab.select("#user_login")
await account.send_keys(kktix_account)
#await tab.sleep(0.1)
submit = await tab.select("input[type='submit'][name]") password = await tab.select("#user_password")
await submit.click() await password.send_keys(kktix_password)
#await tab.sleep(0.1)
await tab.sleep(0.3) submit = await tab.select("input[type='submit'][name]")
tab = await driver.get(signout_url) await submit.click()
await tab.sleep(0.3)
await tab.sleep(0.5)
#tab = await tab.get(signout_url)
signout = await tab.select("a[href='/users/sign_out']")
await signout.click()
await tab.sleep(0.5)
except Exception as e: except Exception as e:
print(e)
if str(e)=="coroutine raised StopIteration":
break
pass pass

View File

@ -46,7 +46,7 @@ URL_CHROME_DRIVER = 'https://chromedriver.chromium.org/'
URL_FIREFOX_DRIVER = 'https://github.com/mozilla/geckodriver/releases' URL_FIREFOX_DRIVER = 'https://github.com/mozilla/geckodriver/releases'
URL_EDGE_DRIVER = 'https://developer.microsoft.com/zh-tw/microsoft-edge/tools/webdriver/' URL_EDGE_DRIVER = 'https://developer.microsoft.com/zh-tw/microsoft-edge/tools/webdriver/'
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
def load_translate(): def load_translate():
translate = {} translate = {}