initialized work folder to git
This commit is contained in:
parent
aa877f09c3
commit
4d91d62d86
9
LICENSE
9
LICENSE
@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
54
README.MD
Normal file
54
README.MD
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
# EpiCeaBot
|
||||
Epicea is een ticketswap bot die tickets voor een event reserveerd. De vervolg stappen zijn voor de gebruiker zelf om uit te voeren.
|
||||
|
||||
## Hoe werkt het?
|
||||
Epicea bot zal vragen naar een email adres die je gebruikt bij het aanmelden op ticketswap. Vervolgens zal er automatisch een browser geopend worden waarin dit emailadres ingevuld wordt.
|
||||
|
||||
Wanneer dit succesvol is gedaan zal de terminal vragen naar de code die zojuist in de mail is ontvangen. Vervolgens zal Epicea deze code in de browser invullen en inloggen.
|
||||
|
||||
Wanneer er ingelogd is zal Epicea een link vragen van het event. Deze zal hij uitsluitend in de gaten houden. Wanneer er een ticket vrij komt zal hij proberen deze te reserveren. Ticketswap houdt deze 10 minuten vast. ZORG DUS DAT JE IN DEZE TIJD HEM OOK ECHT KOOPT!!
|
||||
|
||||
## Stappen
|
||||
1: Install alle packages
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
2: Run het script vanuit een terminal in de werkfolder
|
||||
|
||||
```py
|
||||
python main.py
|
||||
```
|
||||
3: Vul je mailadres in waarop je je een notificatie wilt ontvangen (ex: Johndoe@gmail.com)
|
||||
4: Vul je mailadres in die je gebruikt bij ticketswap (ex: Johndoe@gmail.com)
|
||||
5: Vul de code in in de TERMINAL die je zojuist hebt ontvangen (ex: twysad)
|
||||
6: Vul de tickestwap link in die je wilt kopen (ex: https://www.ticketswap.nl/event/ari-lennox/regular-tickets/a6ae941c-3e7e-40ff-a059-77ac5091d0b9/2775053)
|
||||
7: Koop de tickets wanneer dit aangegeven word
|
||||
|
||||
## Setup
|
||||
Zorg ervoor dat een python versie geinstalleerd is.
|
||||
```
|
||||
python -version
|
||||
```
|
||||
anders download deze
|
||||
Kijk of pip geinstalleerd is
|
||||
```
|
||||
pip -v
|
||||
```
|
||||
anders installeer deze
|
||||
Maak een .env file in de main directory.
|
||||
Zet daar de volgende waardes
|
||||
```
|
||||
HOST_EMAIL = "YOUR HOST GMAIL"
|
||||
HOST_PASS = "PASSWORD FOR YOUR MAIL"
|
||||
```
|
||||
Om app emails in te schakelen op google volg de volgende stappen:
|
||||
|
||||
1. Ga naar https://myaccount.google.com/security
|
||||
2. Klik op 2FA
|
||||
3. Klik op App Passwords.
|
||||
4. Voeg hier dan een password toe en gebruik deze in je ENV bestand
|
||||
|
||||
## Notes
|
||||
Deze repo is voor educational purposes only. Het gebruik van bots is illegaal en daarom dus niet aan geraden!
|
167
main.py
Normal file
167
main.py
Normal file
@ -0,0 +1,167 @@
|
||||
""" Ticket swap bot """
|
||||
import json
|
||||
import time
|
||||
import requests
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
try:
|
||||
from BeautifulSoup import BeautifulSoup
|
||||
except ImportError:
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
HOST = "https://www.ticketswap.nl"
|
||||
|
||||
class TicketSwap:
|
||||
def __init__(self):
|
||||
self.receive_mail = ""
|
||||
self.main_driver = webdriver.Chrome()
|
||||
self.login()
|
||||
self.has_tickets = False
|
||||
|
||||
def login(self):
|
||||
self.receive_mail = input('Notifications email: ')
|
||||
username = input('Ticketswap email: ')
|
||||
self.main_driver.get(HOST)
|
||||
|
||||
# wait for lang buttons
|
||||
time.sleep(1)
|
||||
|
||||
try:
|
||||
lang_button = self.main_driver.find_element(By.CLASS_NAME, 'e1wv5usg4')
|
||||
lang_button.click()
|
||||
print("done")
|
||||
except:
|
||||
pass
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
try:
|
||||
login_button = self.main_driver.find_element(By.CLASS_NAME, 'e1k05qur1').find_elements(By.TAG_NAME, 'li')[2]
|
||||
login_button.click()
|
||||
# await animation
|
||||
time.sleep(1)
|
||||
|
||||
emailInput = self.main_driver.find_element(By.ID, 'email')
|
||||
emailInput.send_keys(username)
|
||||
emailInput.send_keys(Keys.ENTER)
|
||||
|
||||
email_code = input('Provide code from ticketswap in mailbox: ')
|
||||
keys = self.main_driver.find_element(By.ID, 'one-time-code-input-1')
|
||||
|
||||
keys.send_keys(email_code)
|
||||
keys.send_keys(Keys.ENTER)
|
||||
|
||||
except:
|
||||
print("button not found")
|
||||
exit(1)
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
self.cookies = self.__handle_cookies(self.main_driver.get_cookies())
|
||||
|
||||
if 'token' not in self.cookies:
|
||||
print('username or password is invalid!')
|
||||
self.login()
|
||||
|
||||
def __handle_cookies(self, cookieList):
|
||||
cookies = {}
|
||||
for cookie in cookieList:
|
||||
cookies[cookie['name']] = cookie['value']
|
||||
return cookies
|
||||
|
||||
def start(self):
|
||||
eventurl = input('Type here the event url: ')
|
||||
while self.has_tickets is False:
|
||||
print('Checking for tickets')
|
||||
data = self.get_ticket(eventurl)
|
||||
if data is not False:
|
||||
if self.reserve_ticket(data):
|
||||
self.has_tickets = True
|
||||
self.main_driver.get(HOST + '/cart')
|
||||
|
||||
# wait till reserve time is finished
|
||||
current_time = time.strftime("%H:%M:%S", time.localtime())
|
||||
print(f"Reserved tickets at: {current_time}, Waiting 10 minutes, close if you got tickets")
|
||||
self.send_email(self.receive_mail)
|
||||
|
||||
time.sleep(600)
|
||||
|
||||
if input("Got the tickets(Y for yes N for no)").upper() != "Y":
|
||||
print("FFS be faster next time, u wasted 10 min jerking off, now someone lese got the ticket... starting again...")
|
||||
self.has_tickets = False
|
||||
else:
|
||||
print("congratz!")
|
||||
self.main_driver.quit()
|
||||
exit()
|
||||
|
||||
def get_ticket(self, eventurl):
|
||||
""" Get Cheapest ticket """
|
||||
|
||||
# get html from request
|
||||
response = requests.get(eventurl)
|
||||
html = response.content.decode("utf-8")
|
||||
parsed_html = BeautifulSoup(html, "html.parser")
|
||||
|
||||
# check if the 'no tickets' element is present
|
||||
not_exist = parsed_html.body.find('span', attrs={'class': "css-y9qk84 e1asqgj37"})
|
||||
if not_exist is not None:
|
||||
print("no tickets")
|
||||
return False
|
||||
|
||||
# check if there are any listings
|
||||
urlobject = parsed_html.body.findAll('a', attrs={'data-testid': 'listing'})
|
||||
if urlobject is None:
|
||||
print("no offers")
|
||||
return False
|
||||
|
||||
for item in urlobject:
|
||||
attributes = item.attrs
|
||||
ticket_link = attributes['href']
|
||||
print("got offer")
|
||||
return ticket_link
|
||||
|
||||
print('Possible that you have the wrong event url')
|
||||
return False
|
||||
|
||||
def reserve_ticket(self, content):
|
||||
""" Reserve ticket """
|
||||
|
||||
self.main_driver.get(content)
|
||||
try:
|
||||
reserve_button = self.main_driver.find_element(By.CLASS_NAME, 'css-17jso0u')
|
||||
reserve_button.click()
|
||||
except:
|
||||
print(":( they got sniped in front of you, trying again")
|
||||
time.sleep(5)
|
||||
return False
|
||||
print("RESERVED TICKKEttt!!!")
|
||||
time.sleep(3)
|
||||
return True
|
||||
|
||||
def send_email(self,recipient):
|
||||
subject = "Email Subject"
|
||||
body = "Je kan je kaartjes kopen man! ren naar je pc!!!"
|
||||
sender = os.getenv('HOST_EMAIL')
|
||||
password = os.getenv('HOST_PASS')
|
||||
|
||||
msg = MIMEText(body)
|
||||
msg['Subject'] = "JE HEBT TICKETS!!"
|
||||
msg['From'] = sender
|
||||
msg['To'] = recipient
|
||||
smtp_server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
|
||||
smtp_server.login(sender, password)
|
||||
smtp_server.sendmail(sender, recipient, msg.as_string())
|
||||
smtp_server.quit()
|
||||
|
||||
if __name__ == "__main__":
|
||||
load_dotenv()
|
||||
t = TicketSwap()
|
||||
t.start()
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
selenium
|
||||
requests
|
||||
bs4
|
||||
python-dotenv
|
Loading…
x
Reference in New Issue
Block a user