-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path28c3.py
70 lines (49 loc) · 1.85 KB
/
28c3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import requests
from BeautifulSoup import BeautifulSoup
from time import sleep
s = requests.session()
username = ''
password = ''
print "CCC-Presale 28C3 Script by @sctan [https://github.com/szechuen/CCC-Presale]"
# Sign In
print "Accessing Sign In..."
while True:
sign_in = s.get("https://presale.events.ccc.de/accounts/sign_in")
if sign_in.ok: break
print "Request Error - Retrying..."
sign_in_soup = BeautifulSoup(sign_in.content)
account_post = {}
for item in sign_in_soup.findAll("input", type="hidden"): account_post[item['name']] = item['value']
for item in sign_in_soup.findAll("input", type="submit"): account_post[item['name']] = item['value']
account_post['account[username]'] = username
account_post['account[password]'] = password
account_link = "https://presale.events.ccc.de" + sign_in_soup.find("form")['action']
# Account
print "Accessing Account..."
while True:
account = s.post(account_link, data=account_post)
if account.ok: break
print "Request Error - Retrying..."
account_soup = BeautifulSoup(account.content)
ordered = False
page = account
soup = account_soup
while not ordered:
post = {}
for item in soup.findAll("input", type="hidden"): post[item['name']] = item['value']
for item in soup.findAll("input", type="submit"): post[item['name']] = item['value']
link = "https://presale.events.ccc.de" + soup.find("form")['action']
while True:
page = s.post(link, data=post)
if page.ok: break
print "Request Error - Retrying..."
soup = BeautifulSoup(page.content)
last = open("last.html", "w")
last.write(soup.prettify())
last.close()
if soup.find(text=lambda(x): x.find("There are currently not enough tickets available") != -1):
print "Not Open - Sleeping before retrying..."
sleep(1)
else:
print "Ordered :D"
ordered = True