Commit 4627eba9 authored by BooDonky's avatar BooDonky
Browse files

Webbot succefully created

parent cf84b0b2
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
from time import gmtime, strftime
from selenium.webdriver.support.ui import Select
import pickle
import time
import datetime
from tools.web_function_tools import *
#============================================================================
url = "https://www.bataclan.fr/"
# Seiten zur Booking
#url_bookingsite = "https://www.bataclan.fr/en/event/cult-of-ya-fest_2022-01-15/" # ===> Main Cult of Ya Link
url_bookingsite = "https://www.bataclan.fr/en/event/david-carreira-_2022-02-11/"
#url_bookingsite = "https://www.bataclan.fr/en/event/the-jesus-mary-chain_2021-12-05/"
#url_bookingsite = "https://www.bataclan.fr/evenement/alvaro-soler_2022-03-02/"
# Timer wann es refreshen sollte
start_time = datetime.datetime.now()
set_time = start_time.replace(hour=20, minute=45, second=55, microsecond=0)
# set_time = start_time.replace(hour=12, minute=0, second=0, microsecond=0) # ===> Time for Concert
# Tickets anzahl zu kaufen
number_of_tickets = '5'
# Login Data
email = "dominik.nguyen98@gmx.ch"
pw = "JetwinLecktGerne69"
# Kreditkarte Informationen
cardnumber = "5178508831917460"
cvv = "225"
expire_date = '12'
expire_year = '22'
holder_name = "Max Hilfiger"
#==========================================================================
driver = webdriver.Chrome()
driver.get(url)
#cookies_saver(driver)
#cookies_loader(driver)
#===========================================================================
if __name__ == '__main__':
# Gibt Login Daten ein
login(driver, email, pw)
# Springt auf die Bookingsite
searcher(driver, url_bookingsite)
# Entweder Erste oder Zweite booker Funktion auswählen
booker_with_site_refresher(driver, set_time)
#booker(driver,number_of_tickets)
card_information(driver,cardnumber,cvv,expire_date,expire_year,holder_name)
# file: ~/.gitignore_global
.DS_Store
.idea
\ No newline at end of file
../.idea
\ No newline at end of file
from time import gmtime, strftime
import time
import datetime
boolean = True
while boolean:
#start_time = strftime("%H:%M:%S", gmtime())
start_time = datetime.datetime.now()
print(start_time)
time.sleep(1)
set_time = start_time.replace(hour=11, minute=56, second=50, microsecond=0)
if(start_time >= set_time):
print("Success")
boolean = False
while True:
if (browser.find_elements_by_xpath(
'//*[@id="layoutPage"]/div[1]/div/div/div[3]/div[4]/div[2]/div/section/div[1]/div/button/div')):
break
else:
driver.refresh
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions as EC
from tools.web_function_tools import get_cookies_values,cookie_adder
from selenium.webdriver.support.ui import Select
import time
import pickle
def cookies_saver(driver):
# storing the cookies
pickle.dump(driver.get_cookies(), open("cookies.pkl", "wb"))
driver.quit()
def cookies_loader(driver):
# loading the stored cookies
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
# adding the cookies to the session through webdriver instance
driver.add_cookie(cookie)
driver.refresh()
def login(driver):
driver.find_element_by_xpath("/html/body/aside[1]/a").click()
driver.find_element_by_xpath("//*[@id='block-locale-language']/div/ul/li[1]/a").click()
driver.find_element_by_xpath("//*[@id='edit-name']").send_keys(email)
driver.find_element_by_xpath("//*[@id='edit-pass']").send_keys(pw)
time.sleep(2)
driver.find_element_by_xpath("//a[text()='Ok, tout accepter']").click()
driver.find_element_by_xpath("//*[@id='edit-submit']").click()
# Nur für Cookies
#time.sleep(2)
#cookies_saver(driver)
def searcher(driver,url_bookingsite):
# driver.get("https://www.bataclan.fr/en/event/cult-of-ya-fest_2022-01-15/")
driver.get(url_bookingsite)
#cookies_loader(driver)
# driver.execute_script("document.body.style.zoom='50%'")
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(1)
def booker(driver,nt):
driver.find_element_by_xpath("//span[text()='Book now']|//span[text()='Réserver']").click()
time.sleep(1)
#driver.find_element_by_xpath("//button[@class='ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close']").click()
driver.find_element_by_xpath("//li[starts-with(@data-name,'category 1')]|//li[starts-with(@data-name,'categorie 1')]" ).click()
# driver.execute_script("document.body.style.zoom='80%'")
time.sleep(2)
select = Select(driver.find_element_by_tag_name("select"))
# select by visible text
try:
select.select_by_visible_text(nt)
time.sleep(1)
except:
select.select_by_visible_text('4')
time.sleep(1)
driver.find_element_by_xpath("//*[starts-with(@id,'edit-submit-')]").click()
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//*[@id='new-checkout-button']")))
element.click()
# driver.find_element_by_xpath("//*[@id = 'new-checkout-button']").click()
time.sleep(2)
def card_information(driver,cardnumber,cvv,expire_date,expire_year,holder_name):
driver.find_element_by_xpath("//*[@id='edit-paybox-card-number']").send_keys(cardnumber)
driver.find_element_by_xpath("//*[@id='edit-paybox-security-code']").send_keys(cvv)
driver.find_element_by_xpath("//*[@id='edit-paybox-holder-name']").send_keys(holder_name)
select2 = Select(driver.find_element_by_xpath("//*[@id='edit-paybox-end-month']"))
select2.select_by_value(expire_date)
select3 = Select(driver.find_element_by_xpath("//*[@id='edit-paybox-end-year']"))
select3.select_by_value(expire_year)
driver.find_element_by_xpath("//*[@id='edit-panes-termsofuse-termsofuse']").click()
#driver.find_element_by_xpath("//*[@id='new-confirm-button']/span/span").click()
#============================================================================
url = "https://www.bataclan.fr/"
#url_bookingsite = "https://www.bataclan.fr/en/event/cult-of-ya-fest_2022-01-15/" # ===> Main Cult of Ya Link
#url_bookingsite = "https://www.bataclan.fr/en/event/david-carreira-_2022-02-11/"
#url_bookingsite = "https://www.bataclan.fr/en/event/the-jesus-mary-chain_2021-12-05/"
url_bookingsite = "https://www.bataclan.fr/evenement/alvaro-soler_2022-03-02/"
number_of_tickets = '5'
email = "dominik.nguyen98@gmx.ch"
pw = "GoogleCool11"
cardnumber = "5178508831917460"
cvv = "225"
expire_date = '12'
expire_year = '22'
holder_name = "Max Hilfiger"
#==========================================================================
driver = webdriver.Chrome()
driver.get(url)
#cookies_saver(driver)
#cookies_loader(driver)
login(driver)
searcher(driver, url_bookingsite)
booker(driver,number_of_tickets)
card_information(driver,cardnumber,cvv,expire_date,expire_year,holder_name)
from csv import DictReader
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions as EC
from time import gmtime, strftime
from selenium.webdriver.support.ui import Select
import pickle
import time
import datetime
def get_cookies_values(file):
with open(file, encoding="utf-8-sig") as f:
dict_reader = DictReader(f)
list_of_dicts = list(dict_reader)
return list_of_dicts
def cookies_saver(driver):
# storing the cookies
pickle.dump(driver.get_cookies(), open("cookies.pkl", "wb"))
driver.quit()
def cookie_adder(driver,cookies):
for i in cookies:
driver.add_cookie(i)
def cookies_loader(driver):
# loading the stored cookies
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
# adding the cookies to the session through webdriver instance
driver.add_cookie(cookie)
driver.refresh()
def login(driver,email,pw):
driver.find_element_by_xpath("/html/body/aside[1]/a").click()
driver.find_element_by_xpath("//*[@id='block-locale-language']/div/ul/li[1]/a").click()
driver.find_element_by_xpath("//*[@id='edit-name']").send_keys(email)
driver.find_element_by_xpath("//*[@id='edit-pass']").send_keys(pw)
time.sleep(2)
driver.find_element_by_xpath("//a[text()='Ok, tout accepter']").click()
driver.find_element_by_xpath("//*[@id='edit-submit']").click()
# Nur für Cookies
# time.sleep(2)
# cookies_saver(driver)
def searcher(driver, url_bookingsite):
# driver.get("https://www.bataclan.fr/en/event/cult-of-ya-fest_2022-01-15/")
driver.get(url_bookingsite)
# cookies_loader(driver)
# driver.execute_script("document.body.style.zoom='50%'")
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(1)
def booker_with_site_refresher(driver, set_time):
boolean = True
while boolean:
start_time = datetime.datetime.now()
print(start_time)
time.sleep(1)
if (start_time >= set_time):
print("Success")
boolean = False
while True:
try:
driver.find_element_by_xpath("//span[text()='Book now']|//span[text()='Réserver']").click()
break
except:
driver.refresh()
print("Still refreshing site...")
time.sleep(1)
driver.find_element_by_xpath(
"//li[starts-with(@data-name,'category 1')]|//li[starts-with(@data-name,'categorie 1')]").click()
# driver.execute_script("document.body.style.zoom='80%'")
time.sleep(2)
select = Select(driver.find_element_by_tag_name("select"))
# select by visible text
try:
select.select_by_visible_text(nt)
time.sleep(1)
except:
select.select_by_visible_text('4')
time.sleep(1)
driver.find_element_by_xpath("//*[starts-with(@id,'edit-submit-')]").click()
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//*[@id='new-checkout-button']")))
element.click()
# driver.find_element_by_xpath("//*[@id = 'new-checkout-button']").click()
time.sleep(2)
def booker(driver, nt):
driver.find_element_by_xpath("//span[text()='Book now']|//span[text()='Réserver']").click()
time.sleep(1)
# driver.find_element_by_xpath("//button[@class='ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close']").click()
driver.find_element_by_xpath(
"//li[starts-with(@data-name,'category 1')]|//li[starts-with(@data-name,'categorie 1')]").click()
# driver.execute_script("document.body.style.zoom='80%'")
time.sleep(2)
select = Select(driver.find_element_by_tag_name("select"))
# select by visible text
try:
select.select_by_visible_text(nt)
time.sleep(1)
except:
select.select_by_visible_text('4')
time.sleep(1)
driver.find_element_by_xpath("//*[starts-with(@id,'edit-submit-')]").click()
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//*[@id='new-checkout-button']")))
element.click()
# driver.find_element_by_xpath("//*[@id = 'new-checkout-button']").click()
time.sleep(2)
def card_information(driver, cardnumber, cvv, expire_date, expire_year, holder_name):
driver.find_element_by_xpath("//*[@id='edit-paybox-card-number']").send_keys(cardnumber)
driver.find_element_by_xpath("//*[@id='edit-paybox-security-code']").send_keys(cvv)
driver.find_element_by_xpath("//*[@id='edit-paybox-holder-name']").send_keys(holder_name)
select2 = Select(driver.find_element_by_xpath("//*[@id='edit-paybox-end-month']"))
select2.select_by_value(expire_date)
select3 = Select(driver.find_element_by_xpath("//*[@id='edit-paybox-end-year']"))
select3.select_by_value(expire_year)
driver.find_element_by_xpath("//*[@id='edit-panes-termsofuse-termsofuse']").click()
# driver.find_element_by_xpath("//*[@id='new-confirm-button']/span/span").click()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment