简体   繁体   中英

Python login different accounts through a loop

I want to loop through multiple account after closing one account and i want to give the password and username from excel file

username = '********'
password = '********'
URL = 'HTTP://Facebook/'
driver = web driver. Chrome("/web-drivers/chrome-driver")
driver.get(URL)
driver.find_element_by_id('email').send_keys(username)
driver.find_element_by_id('pass').send_keys(password)
time.sleep(2)
driver.find_element_by_id('login-button').click()
time.sleep(10)
driver.close()

create a list of emails and passwords

list_of_mails = ["ex@ex.com","ax@ax.com"]
list_of_passwords = ["abc1234","axpassword"]

put them in order in the list

for a,b in list_of_mails,list_of_passwords:
   a = username
   b = password

and then run the rest of your code in the for loop.

make sure to change ip addresses when you do this. Facebook might block the selenium driver.

or at least put a time.sleep in

如果您想直接登录表单帐户,您必须使用 xlrd 或 openyxl 等库从您的 excel 文件中读取并从您的 excel 文件中导入您的用户,然后您可以直接使用这些用户值登录到您的帐户。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM