Skip to content

Instantly share code, notes, and snippets.

@osteth
Last active August 31, 2019 00:59
Show Gist options
  • Save osteth/95ea360ce80ede5e8f854f6304c1ad88 to your computer and use it in GitHub Desktop.
Save osteth/95ea360ce80ede5e8f854f6304c1ad88 to your computer and use it in GitHub Desktop.
A selenium script that will order Free Tmobile promo wifi hot spots in bulk. Just set the variables with your own order info and run it. Requires Chromedriver. Suggest Anaconda.
# coding: utf-8
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__title__ = "Tmobile hotsport bulk order script."
__summary__ = "A selenium script that will order Free Tmobile promo wifi hot spots in bulk. Just set the variables with your own order info and run it. Requires Chromedriver. Suggest Anaconda."
__uri__ = "https://sethwahle.com"
__author__ = "Seth Wahle"
__copyright__ = "Copyright 2019, Seth Wahle"
__credits__ = [""]
__license__ = "GPL"
__version__ = "0.0.1"
__maintainer__ = "Seth Wahle"
__email__ = "Seth@SethWahle.com"
__date__ = "8/30/2019"
__status__ = "Development"
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 EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.select import Select
import random, time
'''This script will order any number of free hotspots from Tmobiles free hotspot promo.'''
options = Options()
options.add_experimental_option("prefs", {
"safebrowsing.enabled": True
})
#applies options to the webdriver
driver = webdriver.Chrome(chrome_options=options)
def rand_phone():
n = '0000000000'
while '9' in n[3:6] or n[3:6]=='000' or n[6]==n[7]==n[8]==n[9]:
n = str(random.randint(10**9, 10**10-1))
return n[:3] + '-' + n[3:6] + '-' + n[6:]
def countdown(t):
while t:
mins, secs = divmod(t, 60)
timeformat = '{:02d}:{:02d}'.format(mins, secs)
print(timeformat, end='\r')
time.sleep(1)
t -= 1
print('Moving on!')
first = ''
last = ''
phone = rand_phone()
email_tag = 'tmo'
email_domain = '@sharklasers.com'
state = ''
Address = ''
city = ''
zipcode = ''
loop_starting_number = 0
loop_ending_number = 10
def get_hotspot(driver, first, last, phone, email_tag, email_domain, state, Address, city, zipcode):
driver.get("https://www.t-mobile.com/offers/free-trial")
#setup wait timer and wait for page to load
wait = WebDriverWait(driver, 120)
#element = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#firstName")))
#locate all the fields to be filled
first_field = driver.find_element_by_css_selector("#firstName")
last_field = driver.find_element_by_css_selector("#lname")
phone_field = driver.find_element_by_css_selector("#phone")
email_field = driver.find_element_by_css_selector("#mail")
email_conf_field = driver.find_element_by_css_selector("#confirmEmail")
#fill out the fields
first_field.send_keys(first)
last_field.send_keys(last)
phone_field.send_keys(phone)
email_field.send_keys(email_tag + str(x) + email_domain)
email_conf_field.send_keys(email_tag + str(x) + email_domain)
#locate the submit button and wait for the form to validate, then submit
element = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#continueCta")))
element.click()
time.sleep(1)
#element = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#backButton")))
#find all the form fields
addr1_field = driver.find_element_by_css_selector("#address1")
addr2_field = driver.find_element_by_css_selector("div.no-padding.color-white.flex-direction > input.input.body-form")
city_field = driver.find_element_by_css_selector("#city")
zip_field = driver.find_element_by_css_selector("#zip")
#fill out the form fields
addr1_field.send_keys(Address)
addr2_field.send_keys(x)
city_field.send_keys(city)
zip_field.send_keys(zipcode)
print('***WAITING for user input!!!*** -- please select the correct state-----')
#locate the submit button and wait for the form to validate, then submit
element = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#submitButton")))
element.click()
#locate the confirm button and wait for the form to validate, then confirm
element = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#submitCta > span")))
element.click()
if __name__ == "__main__":
for x in range(loop_starting_number, loop_ending_number):
print("Ordering Hotspot #" +str(x))
get_hotspot(driver, first, last, phone, email_tag, email_domain, state, Address, city, zipcode)
#close the browser
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment