-1

So basically i am working on a python script that loggs into a twitch account and stays there to generate a viewer.

But my main issue is how do i make this work for multiple accounts.

How to hide alle the Windows, and how can i handle multiple selenium windows ?

Is selenium even good for that or is there a other way ?

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--mute-audio")
driver = webdriver.Chrome("D:\Downloads\chromedriver_win32\chromedriver.exe", chrome_options=chrome_options)


driver.minimize_window()

driver.get('https://www.twitch.tv/login')
search_form = driver.find_element_by_id('login-username')
search_form.send_keys('user')
search_form = driver.find_element_by_id('password-input')
search_form.send_keys('password')
search_form.submit()
driver.implicitly_wait(10)
driver.get('https://www.twitch.tv/channel')
InvolveX
  • 23
  • 2
  • 8

3 Answers3

2

You are definitely able to use Selenium and Python to do this. To run multiple accounts, you will have to utilize multi-threading or create multiple driver objects to manage.

Multithreading example from this thread:

from selenium import webdriver
import threading
import time

def test_logic():
    driver = webdriver.Firefox()
    url = 'https://www.google.co.in'
    driver.get(url)
    # Implement your test logic
    time.sleep(2)
    driver.quit()

N = 5   # Number of browsers to spawn
thread_list = list()

# Start test
for i in range(N):
    t = threading.Thread(name='Test {}'.format(i), target=test_logic)
    t.start()
    time.sleep(1)
    print t.name + ' started!'
    thread_list.append(t)

# Wait for all thre<ads to complete
for thread in thread_list:
    thread.join()

print 'Test completed!'

Each driver will have to use a proxy connection to connect to Twitch on separate IP addresses. I suggest using Opera as it has a built in VPN, makes it a lot easier.

Example of Opera and Selenium from this thread:

from selenium import webdriver
from time import sleep

# The profile directory which Opera VPN was enabled manually using the GUI
opera_profile = '/home/user-directory/.config/opera' 
options = webdriver.ChromeOptions()
options.add_argument('user-data-dir=' + opera_profile)
driver = webdriver.Opera(options=options)
driver.get('https://whatismyipaddress.com')
sleep(10)
driver.quit()

To hide the console for webdrivers you must run them with the "headless" option. Headless for chrome driver.

from selenium import webdriver from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")

Unfortunately headless is not supported in Opera driver, so you must use Chrome or Firefox for this.

Good luck!

  • Welcome to SO! While the contents of the links you provided might answer the question, it is better to include the essential parts of the answer in your post and provide the link for reference, since link only answers become invalid if the linked page changes. – Patrick Klein Nov 19 '20 at 15:42
0

hi you will not be able to create a bot with selenium because even if you manage to connect several accounts on the twitch account, twitch (like youtube) have a system that looks at your IP address and does not increase the number of views if the multiple connection come from the same computer.

-2

You could use a virtual machine or multiple computers on linode.com or aws and then just inject the code into your machine with python there.

CMGroup
  • 1
  • 1