From e704fce889cadba67772c19829d0e601cc55bed2 Mon Sep 17 00:00:00 2001 From: x3Karma Date: Sat, 18 Mar 2023 20:08:12 +0800 Subject: [PATCH] Updated to use selenium new functions and xpath changes for 18/3/2023 --- swag.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/swag.py b/swag.py index a887ce6..81d84a4 100644 --- a/swag.py +++ b/swag.py @@ -11,29 +11,32 @@ def __init__(self, username, pw): self.pw = pw self.driver.get("https://www.swagbucks.com/p/login") sleep(2) - self.driver.find_element_by_xpath("//input[@name=\"emailAddress\"]").send_keys(username) - self.driver.find_element_by_xpath("//input[@name=\"password\"]").send_keys(pw) + self.driver.find_element("xpath", "//input[@name=\"emailAddress\"]").send_keys(username) + self.driver.find_element("xpath", "//input[@name=\"password\"]").send_keys(pw) sleep(2) - self.driver.find_element_by_xpath('//button[@id="loginBtn"]').click() - sleep(100) # time for you to do the thing that proves you are not a bot + self.driver.find_element("xpath", '//button[@id="loginBtn"]').click() + print( "Sleeping..." ) + sleep(15) # time for you to do the thing that proves you are not a bot + print( "Done." ) def survey(self): - self.driver.find_element_by_xpath("//a[contains(@href,'/surveys')]").click() + self.driver.find_element("xpath", "/html/body/div[3]/div[1]/header/nav/div[1]/ul/li[2]/a").click() sleep(2) for i in range(1000): x = random.randint(1,2) y = random.randint(1,4) sleep(y) - self.driver.find_element_by_class_name("surveyDropdownVal").click() + self.driver.find_element("xpath", "/html/body/div[3]/div[3]/div[1]/div[1]/div[1]/div[2]/div[2]/div[2]/div/div[2]/div/div[1]/div/span[2]").click() sleep(x) - string1 = "/html/body/div[4]/div[2]/div[1]/div[1]/div[1]/div[2]/div[2]/div[2]/div/div[2]/div/div[1]/div/div/span[" + str(x) + "]" - self.driver.find_element_by_xpath(string1).click() + string1 = "/html/body/div[3]/div[3]/div[1]/div[1]/div[1]/div[2]/div[2]/div[2]/div/div[2]/div/div[1]/div/div/span[" + str(x) + "]" + + self.driver.find_element("xpath", string1).click() sleep(y) - #self.driver.find_element_by_xpath('//button[@class=surveyDashboardCTA sbCta sbBgPrimaryColor"]') - self.driver.find_element_by_xpath("/html/body/div[4]/div[2]/div[1]/div[1]/div[1]/div[2]/div[2]/div[2]/div/div[2]/div/div[2]/button").click() + #self.driver.find_element("xpath", '//button[@class=surveyDashboardCTA sbCta sbBgPrimaryColor"]') + self.driver.find_element("xpath", "/html/body/div[3]/div[3]/div[1]/div[1]/div[1]/div[2]/div[2]/div[2]/div/div[2]/div/div[2]/button").click() #self.driver.find_elements_by_class_name("surveyDashboardCTA sbCta sbBgPrimaryColor").click() sleep(x) print(i) -my_bot = SwagBot(*your username*, *your password*) +my_bot = SwagBot( "Your username" , "Your password" ) my_bot.survey()