import time import requests from selenium import webdriver from…
- User
import time import requests from selenium import webdriver from selenium.webdriver.chrome.options import Options # Proxy listesi proxies = [ {‘proxy’: ‘104.238.4.215:5778’, ‘username’: ‘Hesenabdulkerimov’, ‘password’: ‘Guneslibineqedi5’}, {‘proxy’: ‘216.173.79.239:6645’, ‘username’: ‘Hesenabdulkerimov’, ‘password’: ‘Guneslibineqedi5’}, {‘proxy’: ‘45.192.145.10:5352’, ‘username’: ‘Hesenabdulkerimov’, ‘password’: ‘Guneslibineqedi5’}, # vb. ] # Chromium profili profile_path = r’C:\Users\Administrator\AppData\Local\Google\Chrome for Testing\User Data\Profile 2\Profile 1\Profile 1’ def join_raffles(proxy): # Proxy yetkilendirmesini ayarla chrome_options = webdriver.ChromeOptions() chrome_options.add_argument(‘–user-data-dir={}’.format(profile_path)) chrome_options.add_argument(‘–proxy-server={}’.format(proxy[‘proxy’])) driver = webdriver.Chrome(options=chrome_options) driver.get(‘http://www.roshtein.com/raffles’) # Raffles sitesine gidilir # JavaScript kodunu çalıştırma driver.execute_script(‘’’ setInterval(function() { const joinButton = document.querySelector(‘.btn-basic.btn-white.btn-corner.btn-medium’); if (joinButton) { joinButton.click(); } else { clearInterval(); } }, 1000); ‘’') time.sleep(45) # 4 saniye beklenir driver.quit() # Tarayıcıdan çıkılır # Raffles sitesine giriş ve işlemler join_raffles(proxies[0]) # Diğer proxylerle tekrarlayan işlemler for i in range(1, len(proxies)): proxy = proxies[i] # Proxy yetkilendirmesi yapılır session = requests.Session() session.proxies = { ‘http’: ‘http://{}:{}@{}’.format(proxy[‘username’], proxy[‘password’], proxy[‘proxy’]), ‘https’: ‘http://{}:{}@{}’.format(proxy[‘username’], proxy[‘password’], proxy[‘proxy’]) } # Raffles sitesine giriş ve işlemler join_raffles(proxy) driver.quit() # Tüm işlemler tamamlandığında tarayıcıdan çıkılır bu neden chronium yerine google chromeyi açıyor?
- Assistant
Selenium ve Chromedriver'ı kullanarak otomasyon yaparken, tarayıcıyı açarken
webdriver.Chrome()şeklinde bir seçenek belirtmezseniz, varsayılan olarak Google Chrome tarayıcısı kullanılır. Bu nedenlewebdriver.Chrome()çağrısında herhangi bir argüman geçmezseniz, otomatik olarak Google Chrome tarayıcısı açılır.Eğer chromium tarayıcısını kullanmak isterseniz,
webdriver.Chrome()yerinewebdriver.Chrome(executable_path='path_to_chromium_executable')şeklinde bir argüman belirtmeniz gerekmektedir, wherepath_to_chromium_executableyour chromium executable file's path.