· 10 years ago · Jul 28, 2016, 01:15 AM
1#!/usr/bin/python
2import re
3import time
4import sys
5import os
6import json
7import mechanize
8import string
9import random
10
11def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
12 return ''.join(random.choice(chars) for _ in range(size))
13
14with open('credentials.json') as f:
15 credentials = json.load(f)
16
17DOB = credentials.get('dob', None)
18
19if len(sys.argv) == 1:
20 print 'input number of accounts to generate'
21 sys.exit(1)
22
23limit = sys.argv[1]
24print 'trying to make ' + limit + 'accounts'
25count = 0
26
27while(True):
28 count = count + 1
29 br = mechanize.Browser()
30 br.set_handle_robots(False)
31 br.addheaders = [('User-agent', 'Firefox')]
32
33 if (count > 1):
34 print 'sleeping for 2 seconds...'
35 time.sleep(2)
36
37 print 'trying to open verification form...'
38 try:
39 br.open("https://club.pokemon.com/us/pokemon-trainer-club/sign-up/")
40 except mechanize.HTTPError, e:
41 print 'error occured! restarting attempt...'
42 print e
43 continue
44 print 'success!'
45
46 print 'filling up form...'
47 br.select_form(name='verify-age')
48 br.form['dob'] = DOB
49 print 'success!'
50 res = br.submit()
51 print 'done submitting age verification!'
52
53 if (br.geturl() != "https://club.pokemon.com/us/pokemon-trainer-club/parents/sign-up"):
54 print 'something went wrong! shutting down lol'
55 sys.exit(1)
56 else:
57 print 'success! moving to the next form...'
58
59 print 'filling up form...'
60 br.select_form(name='create-account')
61 password = id_generator()
62 print password
63 username = 'innocentlampshade' + str(count)
64 print username
65 print 'lecoffeestain+' + username + '@gmail.com'
66 br.form['username'] = username
67 br.form['password'] = password
68 br.form['confirm_password'] = password
69 br.form['email'] = 'lecoffeestain+' + username + '@gmail.com'
70 br.form['confirm_email'] = 'lecoffeestain+' + username + '@gmail.com'
71 br.form['public_profile_opt_in'] = ['False']
72 br.form['terms'] = ['on']
73 print 'success!'
74 res = br.submit()
75 print 'done submitting registration form!'
76
77 if (br.geturl() != "https://club.pokemon.com/us/pokemon-trainer-club/parents/email"):
78 print 'failed! continuing with next account'
79
80 else:
81 print 'success! created account' + USERNAME + str(count) + ":" + PASSWORD
82 f = open("accounts.txt","w")
83 f.write(username + ' ' + password)
84 f.close()
85
86 if (count > limit):
87 break