Skip to content

Commit

Permalink
add kktix auto sign-in sign-out
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Mar 27, 2024
1 parent 60f8387 commit 4ca9e4f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
42 changes: 26 additions & 16 deletions kktix_signout.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,31 +117,41 @@ 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:
tab = await driver.get(signin_url)
#html = await tab.get_content()
#await tab.sleep(0.1)
#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")
await password.send_keys(kktix_password)
#await tab.sleep(0.1)

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)
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)

submit = await tab.select("input[type='submit'][name]")
await submit.click()

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


Expand Down
2 changes: 1 addition & 1 deletion kktix_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
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 = {}
Expand Down

0 comments on commit 4ca9e4f

Please sign in to comment.