I have a text file with usernames and passwords. The text file is formatted like this:
username1:password1
username2:password2
username3:password3
I want to grab the first line, split it to "username1" and "password1", and then post to this:
br.form['login'] = 'username1'
br.form['passwd'] = 'password1'
After that, I want it to repeat and move onto username2:password2.
How can this be done?
Assuming no :
characters in your usernames or passwords:
with open('myfile.txt') as f:
credentials = [x.strip().split(':', 1) for x in f]
for username, password in credentials:
# your code here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With