Python Forum

Full Version: want to make auto login with data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi i made script with selenium for auto login but i want to get data from .txt file can u help me?
format is user:pass or mail:pass
hi i made script with selenium for auto login but i want to get data from .txt file . format is user:pass or mail:pass

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
import time
browser = webdriver.Chrome()




browser.get("site")

browser.find_element_by_id("login-username").send_keys(email)
browser.find_element_by_id("login-password").send_keys(pass)
browser.find_element_by_id("login-button").click()

time.sleep(5)

browser.find_element_by_css_selector("._95e9f2bdfb-scss > button:nth-child(1)").click()


also i did this for get data

filepath = "combofile" 
combo = open(filepath,"r")  
line = list(filepath)    
for line in combo :        
    temp = line.strip().split(":") or both
    email = temp[0]       
    password = temp[1]   
but didnt work, with this method using all emails/passwords in one request
Hello R3born

Please use the login code inside the for loop
Hence, your final code should look like this.
browser.get("site")
filepath = "combofile" 
combo = open(filepath,"r")  
line = list(filepath)    
for line in combo :        
    temp = line.strip().split(":") or both
    email = temp[0]       
    pass = temp[1]   
    browser.find_element_by_id("login-username").send_keys(email)
    browser.find_element_by_id("login-password").send_keys(pass)
    browser.find_element_by_id("login-button").click()
    time.sleep(5)
    browser.find_element_by_css_selector("._95e9f2bdfb-scss > button:nth-child(1)").click()
(Sep-11-2020, 11:43 AM)wintenrod Wrote: [ -> ]Hello R3born

Please use the login code inside the for loop
Hence, your final code should look like this.
browser.get("site")
filepath = "combofile" 
combo = open(filepath,"r")  
line = list(filepath)    
for line in combo :        
    temp = line.strip().split(":") or both
    email = temp[0]       
    pass = temp[1]   
    browser.find_element_by_id("login-username").send_keys(email)
    browser.find_element_by_id("login-password").send_keys(pass)
    browser.find_element_by_id("login-button").click()
    time.sleep(5)
    browser.find_element_by_css_selector("._95e9f2bdfb-scss > button:nth-child(1)").click()

thanks!
my last question is how can i open new tab with new user:pass data?