Skip to content

Instantly share code, notes, and snippets.

@thesanjeetc
Created September 19, 2020 17:25
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save thesanjeetc/2e78ab31047d8c5075e947a0afbe50be to your computer and use it in GitHub Desktop.
Save thesanjeetc/2e78ab31047d8c5075e947a0afbe50be to your computer and use it in GitHub Desktop.
from fake_useragent import UserAgent
from selenium import webdriver
from random import randrange
import time
ua = UserAgent(verify_ssl=False)
user_agent = ua.random
print("USER AGENT: " + user_agent)
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-agent=" + user_agent)
driver = webdriver.Chrome(chrome_options=chrome_options)
def getCode():
id = randrange(100000000000000)
url = "https://www.papajohnsfeedback.com/GBR?GUID=" + str(id)
print(url)
driver.get(url)
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
driver.find_element_by_xpath(
"//div[contains(@class, 'Opt1')]/span").click()
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
driver.find_element_by_xpath(
"//div[contains(@title, 'Highly Satisfied')]").click()
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
stars = driver.find_elements_by_css_selector("[title^='Highly Satisfied']")
for div in stars:
time.sleep(1)
div.click()
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
driver.find_element_by_xpath(
"//td[contains(@class, 'Opt5')]/span").click()
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
driver.find_element_by_xpath(
"//div[contains(@class, 'Opt1')]/span").click()
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
driver.find_element_by_xpath(
"//td[contains(@class, 'Opt2')]/span").click()
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
driver.find_element_by_xpath(
"//div[contains(@class, 'Opt6')]/span").click()
time.sleep(1)
driver.find_element_by_id('NextButton').click()
time.sleep(1)
code = driver.find_element_by_class_name(
'ValCode').get_attribute("innerHTML").split(' ')[2]
return code
codes = []
for i in range(0, 10):
c = getCode()
print("CODE: " + c)
codes.append(c)
time.sleep(3)
print(codes)
driver.quit()
@helish88
Copy link

Привет с habrahabr. Шикарно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment