Python Forum
want to make auto login with data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
want to make auto login with data
#1
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
Reply
#2
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
Reply
#3
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()
Reply
#4
(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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to make bot that sends instagram auto password reset code kraixx 2 1,363 Mar-04-2023, 09:59 PM
Last Post: jefsummers
  shutil.move make data corrupt kucingkembar 0 788 Feb-01-2023, 01:30 PM
Last Post: kucingkembar
  How to make a test data file for the full length of definition? MDRI 6 3,537 Apr-16-2021, 01:47 AM
Last Post: MDRI
  in a login interface when i try login with a user supposed to say test123 but nothing NullAdmin 3 2,259 Feb-20-2021, 04:43 AM
Last Post: bowlofred
  How to make a simple automation process of login using "if condition" soimba 3 2,742 Jan-07-2020, 11:58 PM
Last Post: SheeppOSU
  How to make a function for auto generated id sunnyarora 2 2,909 May-03-2019, 12:47 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020