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,8 +117,7 @@ async def kktix_signin_nodriver(kktix_account, kktix_password):
driver = await uc.start()
profile_url = "https://kktix.com/users/edit"
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:
try:
@ -127,21 +126,32 @@ async def kktix_signin_nodriver(kktix_account, kktix_password):
#await tab.sleep(0.1)
#print(html)
account = await tab.select("#user_login")
await account.send_keys(kktix_account)
#await tab.sleep(0.1)
x = await tab.js_dumps('window')
#print(x)
#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)
password = await tab.select("#user_password")
await password.send_keys(kktix_password)
#await tab.sleep(0.1)
password = await tab.select("#user_password")
await password.send_keys(kktix_password)
#await tab.sleep(0.1)
submit = await tab.select("input[type='submit'][name]")
await submit.click()
submit = await tab.select("input[type='submit'][name]")
await submit.click()
await tab.sleep(0.3)
tab = await driver.get(signout_url)
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:
print(e)
if str(e)=="coroutine raised StopIteration":
break
pass

View File

@ -46,7 +46,7 @@ URL_CHROME_DRIVER = 'https://chromedriver.chromium.org/'
URL_FIREFOX_DRIVER = 'https://github.com/mozilla/geckodriver/releases'
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():
translate = {}