Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ This is a script made to automate all the entry methods, to see the supoorted entries look here:
- https://gleam.io/examples ( Gleam Example Campaigns ) right now there's no way to change the 'participant' """
- from selenium import webdriver
- from selenium.webdriver.common.keys import Keys
- from selenium.common.exceptions import NoSuchElementException
- from selenium.common.exceptions import ElementNotVisibleException
- from time import sleep
- options = webdriver.ChromeOptions()
- options.add_argument("user-data-dir=C:\UsersHomeDesktopProjects")
- driver = webdriver.Chrome(chrome_options=options)
- def entering_process(window_before, i):
- try:
- # Responsible for visit only part #
- driver.find_element_by_css_selector('#{} .btn-large'.format(i)).click()
- sleep(1)
- window_after = driver.window_handles[1]
- driver.switch_to.window(window_after)
- sleep(4)
- driver.close()
- driver.switch_to.window(window_before)
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for the what username/quote you used part #
- username_quote = driver.find_element_by_xpath('//input[@class="ng-empty ng-invalid ng-invalid-required ng-dirty ng-valid-parse ng-touched"]')
- username_quote.click()
- username_quote.clear()
- username_quote.send_keys('Random Name/Quote')
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for the blog post part #
- blog_post = driver.find_element_by_xpath('//input[@class="ng-valid ng-empty ng-valid-maxlength ng-dirty ng-valid-parse ng-touched]')
- blog_post.click()
- blog_post.clear()
- blog_post.send_keys('https://testing.googleblog.com/')
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for the opinion part #
- opinion = driver.find_element_by_xpath('//textarea[@name="data"]')
- opinion.click()
- opinion.clear()
- opinion.send_keys('Random Opinion')
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for the twitch subscribers part #
- driver.find_element_by_xpath("//*[contains(text(), 'Sorry, only subscribers of')]")
- driver.find_element_by_partial_link_text('Cancel').click()
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for the view instagram part #
- driver.find_element_by_xpath('//img[@class="EmbeddedMediaImage"]')
- sleep(1)
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for choose image part #
- driver.find_element_by_xpath('//a[@class="image ng-isolate-scope"]').click()
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for checkbox list part #
- driver.find_element_by_xpath('//label[@class="radio ng-binding"]').click()
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for other type of checkbox list part #
- driver.find_element_by_xpath('//label[@class="checkbox ng-binding"]').click()
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for blog post dropdown part part #
- driver.find_element_by_xpath('//select[@ng-model="entryState.formData[entry_method.id]["blog"]"]').click()
- driver.find_element_by_xpath('//option[@label="Sem título"]').click()
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for tweet with this hashtag part #
- driver.find_element_by_xpath('//span[@class="twitter-label"]').click()
- window_after = driver.window_handles[1]
- driver.switch_to.window(window_after)
- driver.find_element_by_xpath('//input[@value="Tweetar"]').click()
- driver.switch_to.window(window_before)
- driver.find_element_by_xpath('//a[@ng-click="showExtra(entry_method)"]').click()
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for the pin this part #
- driver.find_element_by_xpath('//a[@data-pin-log="button_pinit"]').click()
- window_after = driver.window_handles[1]
- driver.switch_to.window(window_after)
- driver.find_element_by_xpath('//div[@data-test-id="BoardPickerSaveButton"]').click()
- driver.close()
- driver.switch_to.window(window_before)
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for blog post dropdown part #
- driver.find_element_by_xpath('//a[@back-img="twitter.thumb | removeProtocol"]').click()
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for the youtube watch part #
- driver.find_element_by_xpath('//iframe[@title="YouTube video player"]')
- driver.switch_to.frame(driver.find_element_by_xpath('//iframe[@class="cover-video youtube youtube-lazy-init"]'))
- driver.find_element_by_class_name('ytp-large-play-button').click()
- sleep(1)
- driver.find_element_by_class_name('ytp-play-button').click()
- ActionChains(driver).send_keys(Keys.END).perform()
- driver.switch_to_default_content()
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for the share linkedin part #
- driver.find_element_by_xpath('//span[@id="li_ui_li_gen_1518887151266_0"]').click()
- driver.switch_to.window(window_after)
- driver.close()
- driver.switch_to.window(window_before)
- except (ElementNotVisibleException, NoSuchElementException):
- pass
- finally: # Responsible for continue after all variables was checked #
- try:
- # Responsible for clicking the continue button #
- driver.find_element_by_xpath('//button[@ng-click="saveEntryDetails(entry_method)"]').click()
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for clicking the second version of the continue button #
- driver.find_element_by_xpath('//button[@ng-click="videoWatched(entry_method)"]').click()
- except (ElementNotVisibleException, NoSuchElementException):
- try:
- # Responsible for clicking the arrow to close the box if the continue wasn't available #
- driver.find_element_by_xpath('//i[@class="fa fa-chevron-down"]').click()
- except (ElementNotVisibleException, NoSuchElementException):
- print('No other continue method available, better try to implement it')
- pass
- def start_process():
- """ Start the process of entering the givewaways,
- filtering by variables and then executing the measures """
- url = input('Enter the Gleam link: ')
- driver.get(url)
- try:
- # Check if there is the unlock entries warning #
- window_before = driver.window_handles[0]
- driver.find_element_by_xpath('//h3[@ng-if="!isReward()"]') # Unlock element #
- ids = driver.find_elements_by_class_name('entry-method')
- ids = [x.get_attribute('id') for x in ids]
- for i in ids:
- driver.find_element_by_id(i).click()
- sleep(1)
- entering_process(window_before, i)
- except (ElementNotVisibleException, NoSuchElementException):
- # Start the normal process if the unlock warning was not found or finished #
- window_before = driver.window_handles[0]
- ids = driver.find_elements_by_class_name('entry-method')
- ids = [x.get_attribute('id') for x in ids]
- for i in ids:
- driver.find_element_by_id(i).click()
- sleep(1)
- entering_process(window_before, i)
- if __name__ == "__main__":
- print('Starting')
- start_process()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement