E
E
Ernest Vardanyan2020-05-17 21:29:10
Python
Ernest Vardanyan, 2020-05-17 21:29:10

How to use proxy in selenium?

I use selenium when parsing and the bot receives information from the parser and sends it to the channel, but I have an unofficial sat, it is forbidden in Russia, that is, I need a vpn of the country where it is allowed, this is the Netherlands, I decided to buy a Dutch proxy, tell me if it is possible to use it correctly proxy so that I can enter without any vpn purchases, I paste the code

from telebot import apihelper
import requests
from selenium import webdriver
import telegram
import time


BOT_TOKEN = 'некий токен'

browser = webdriver.Firefox()
browser.maximize_window()

browser.get('https://one-xskbdc.world/ru/live/Mortal-Kombat/1252965-Mortal-Kombat-X/')
HEADERS = {'user-agent':'Mozilla / 5.0 (Windows NT 10.0; WOW64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 80.0.3987.132 YaBrowser / 20.3.2.242 Yowser / 2.5 Safari / 537.36'}


nameone1 = browser.find_element_by_xpath('//*[@id="games_content"]/div/div[1]/div/div/div[2]/div/div[1]/div[1]/a/span').text
print(nameone1)
nameone1_massif=nameone1.split()
del nameone1_massif[-1]
print(nameone1_massif)
if 'Горо' in nameone1_massif[0]:
    if 'Рептилия' in nameone1_massif[1]:
        bot = telegram.Bot(token=BOT_TOKEN)
        bot.send_message(chat_id='некий чат', text='\U0001F4E3Внимание: появилась ставка\U0001F4E3')
        while True:
            browser.find_element_by_xpath('/html/body/div[2]/div[1]/div[2]/div/div/div[4]/div/div/div[1]/div/div/div[2]/div/div[1]/div[1]/a').click()
            time.sleep(15)
            browser.find_element_by_xpath('//*[@id="hottest_games"]/div/div[1]/div/div/div[2]/div/ul/li[1]/a').click()
            time.sleep(15)
            win = browser.find_element_by_xpath('//*[@id="allBetsTable"]/div[1]/div[1]/div/div[2]/div[2]/span[2]').text
            print(win)
            score1=browser.find_element_by_xpath('/html/body/div[2]/div[1]/div[2]/div/div/div[2]/div/div/div/div[1]/div[1]/div/div[2]/div/div/div[2]/div/div/div[2]/div[1]').text
            print(score1)
            bot = telegram.Bot(token=BOT_TOKEN)
            bot.send_message(chat_id='некий  чат', text='\U0001F3AE' + '\n' +'\U0001F4CC Ставим на победу - 1' + '\n'+'\U0001F525' + ' '+win  )
    else:
        print('Проверьте бой'
else:
    print('Проверьте бой')


browser.close()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alternativshik, 2020-05-18
@alternativshik

https://lmgtfy.com/?q=selenium+python+proxy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question