Skip to content

Instantly share code, notes, and snippets.

@luxu
Created December 28, 2019 23:16
Show Gist options
  • Select an option

  • Save luxu/118f838f233d3919d2401eef459d5e4e to your computer and use it in GitHub Desktop.

Select an option

Save luxu/118f838f233d3919d2401eef459d5e4e to your computer and use it in GitHub Desktop.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as CondicaoExperada
from selenium.common.exceptions import *
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from time import sleep
import os, random
class RoyaleSelenium:
def __init__(self):
self.driver = webdriver.Chrome()
self.wait = WebDriverWait(
self.driver,
10,
poll_frequency=1,
ignored_exceptions=[
NoSuchElementException,
ElementNotVisibleException,
ElementNotSelectableException,
],
)
@staticmethod
def type_like_a_person(sentence, single_input_field):
""" Essa função basicamente simulará a digitação de uma pessoa"""
print("going to start typing message into message share text area")
for letter in sentence:
single_input_field.send_keys(letter)
sleep(random.randint(1, 5) / 30)
def main(self,url):
driver = self.driver
driver.get(url)
xpath_field_input_tag = '//*[@id="zorium-root"]/div/div[2]/div/div[1]/div/div/div[1]/div/div/div[2]/div/div[2]/form/div[1]/div/div[1]/input'
sleep(random.randint(5, 7) / 30)
field_input_tag = self.wait.until(
CondicaoExperada.element_to_be_clickable(
(By.XPATH, xpath_field_input_tag)
)
)
sleep(random.randint(5, 7) / 30)
field_input_tag.clear()
field_input_tag.send_keys('P9V0VC9R')
sleep(random.randint(5, 7) / 30)
driver.find_element_by_xpath(
'//*[@id="zorium-root"]/div/div[2]/div/div[1]/div/div/div[1]/div/div/div[2]/div/div[2]/form/div[2]/div/div/button'
).click()
xpath_result_cheats = "//div[@class='z-ui-card']"
sleep(random.randint(20, 22) / 30)
xpath_list_chests = "//div[@class='chest']"
result_cheats = self.wait.until(
CondicaoExperada.element_to_be_clickable(
(By.XPATH, xpath_list_chests)
)
)
list_chests = driver.find_elements_by_xpath(xpath_list_chests)
for chest in list_chests:
print(
chest.find_element_by_xpath("//img").get_attribute('src')
)
xpath_update_status = "//div[@class='status']//div"
update_status = driver.find_element_by_xpath(xpath_update_status)
if __name__ == '__main__':
# url = 'https://statsroyale.com/pt/profile/P9V0VC9R'
url = 'https://fam.gg/'
royale = RoyaleSelenium()
royale.main(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment