简体   繁体   English

Python通过循环登录不同的账户

[英]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我想在关闭一个帐户后循环访问多个帐户,并且我想从 excel 文件中提供密码和用户名

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.然后在 for 循环中运行其余的代码。

make sure to change ip addresses when you do this.确保在执行此操作时更改 IP 地址。 Facebook might block the selenium driver. Facebook 可能会阻止 selenium 驱动程序。

or at least put a time.sleep in或者至少花点时间睡觉

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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