N
N
NO1nam2020-03-17 17:05:22
Python
NO1nam, 2020-03-17 17:05:22

How to make it so that would take data from a file?

How to make it so that it would take data from a txt file and log in to the site so infinitely
all data in the form
name:password
name:password
name:password
name:password

from selenium import webdriver
from selenium.webdriver.common.by import By

name = 'ИМЯ ИЗ TXT'
password = 'ПАРОЛЬ ИЗ TXT'

url = 'http://mrush.mobi/'

driver = webdriver.Chrome('C:/Users/root/Desktop/mrush/chromedriver')

driver.get(url)
#Авторизация
driver.find_element_by_css_selector("input[name='name']").send_keys(name)
driver.find_element_by_css_selector("input[name='password']").send_keys(password)
checkboxes = driver.find_elements(By.XPATH, '//input[@type="checkbox"]')
for box in checkboxes:
    try:
        box.click()
    except Exception:
        pass
driver.find_element_by_css_selector("input[type='submit']").click()

#Начинает игру
new = driver.get("http://mrush.mobi/first_attack?attack=1");

#Выход из аккаунта
logout = driver.get("http://mrush.mobi/logout");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dimastbk, 2020-03-17
@NO1nam

A task too common to not be answered on the internet: https://stackoverflow.com/questions/9857731/python...
Read the file line by line into a list, loop through the list, split each element with str.split(": ") and pass this data to the desired function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question