Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- browser = webdriver.Chrome('C:/users/sebastian/desktop/chromedriver.exe')
- class KingdomLikesBot:
- def __init__(self):
- self.main_window = browser.window_handles[0]
- self.popup = None
- self.wait = WebDriverWait(browser, 5)
- def login_KingdomLikes(self, email, pwd):
- """Searches the webpage for the 'email' and 'password' field, enters the email and pwd.
- and clicks 'login' """
- # Locate username and password field
- username = self.wait.until(EC.presence_of_element_located((By.NAME, 'email')))
- password = browser.find_element_by_name('password')
- username.send_keys(email)
- password.send_keys(pwd)
- # Press the login button
- browser.find_element_by_css_selector('#formlogin > div:nth-child(1) > input.button.blue').click()
- def request_facebookLikes_website_section(self):
- """When first logging into kingdom likes, there is multiple ways to earn points.
- This method, requests the 'Facebook Likes' section. """
- but = self.wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#accordian > ul > li.active > ul > li:nth-child(1) > a')))
- but.click()
- browser.get('http://kingdomlikes.com/free_points/facebook-likes')
- bot_1 = KingdomLikesBot()
- input('When you are logged in, press enter.')
- bot_1.request_facebookLikes_website_section()
- css_selector = 'div.container > div > button'
- while True:
- input('Try clicking the like button')
- js_script = ''.join(["var elem = document.querySelector('",
- css_selector,
- "');",
- "if( document.createEvent) {",
- "var evObj = document.createEvent('MouseEvents');",
- "evObj.initEvent( 'mouseover', true, false );",
- "elem.dispatchEvent(evObj);",
- "} else if( document.createEventObject ) {",
- "elem.fireEvent('onmouseover');",
- "}"])
- browser.execute_script(js_script)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement