-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathuserinfo.py
180 lines (163 loc) · 4.81 KB
/
userinfo.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import string
from urllib.request import urlopen
import json
import re
import os
import random
import names
from random_address import real_random_address
addr = real_random_address()
class RandUser():
def __init__(self) -> None:
self.site = 'https://randomuser.me/api/'
self.nat = 'us'
f = open('datasets/addresses-us-all.json')
self.address_json = json.loads(f.read())
self.address = {}
for a in self.address_json['addresses']:
if 'city' in a:
self.address.update({a['postcode']: a})
def rand_user(self, nat = None):
_ = random.choice(list(self.address.keys()))
x = self.address[_]
return {
'street': x['address'],
'city': x['city'],
'state': x['state'],
'zip': x['postcode'],
'name': self.full_name,
'password': self.password,
'email': self.email,
'username': self.username,
'first_name': self.first_name,
'last_name': self.last_name,
'name': self.full_name,
'province': self.get_province(x['state']),
'phone': self.phone
}
@property
def street(self):
_ = random.choice(list(self.address.keys()))
x = self.address[_]
return x['address']
@property
def full_name(self, gender: str = None):
return names.get_full_name(gender)
@property
def first_name(self, gender: str = None):
return names.get_first_name(gender)
@property
def last_name(self, gender: str = None):
return names.get_last_name()
@property
def password(self, length = 8):
lower = string.ascii_lowercase
upper = string.ascii_uppercase
num = string.digits
symbols = string.punctuation
all = lower + upper + num + symbols
temp = random.sample(all,length)
password = "".join(temp)
return password
@property
def phone(self):
first = str(random.randint(100, 999))
second = str(random.randint(1, 888)).zfill(3)
last = (str(random.randint(1, 9998)).zfill(4))
while last in ['1111', '2222', '3333', '4444', '5555', '6666', '7777', '8888']:
last = (str(random.randint(1, 9998)).zfill(4))
return '{}{}{}'.format(first, second, last)
@property
def email(self):
return str(''.join(random.choices(string.ascii_lowercase + string.digits, k = 15))) + '@gmail.com'
@property
def get_random_string(self, length :int = str):
return random.random_string(length)
@property
def get_random_integer(self, length :int = str):
return random.random_integer(length)
@property
def username(self):
return str(''.join(random.choices(string.ascii_lowercase + string.digits, k = 8)))
def get_sho_auto(self):
return {
'address1': addr['address1'],
'address2' : addr['address2'],
'city': addr['city'],
'state': addr['state'],
'zip': addr['postalCode'],
'name': self.full_name,
'password': self.password,
'email': self.email,
'email_or_phone': self.email,
'customer_email': self.email,
'username': self.username,
'first_name': self.first_name,
'country': 'United States',
'last_name': self.last_name,
'company': self.full_name,
# 'province': addr['state'],
'province': self.get_province(addr['state']),
'phone': self.phone
}
def get_province(self, state_name, ret = False):
a= {
"AL": "Alabama",
"AK": "Alaska",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
"DC": "District Of Columbia",
"FL": "Florida",
"GA": "Georgia",
"HI": "Hawaii",
"ID": "Idaho",
"IL": "Illinois",
"IN": "Indiana",
"IA": "Iowa",
"KS": "Kansas",
"KY": "Kentucky",
"LA": "Louisiana",
"ME": "Maine",
"MD": "Maryland",
"MA": "Massachusetts",
"MI": "Michigan",
"MN": "Minnesota",
"MS": "Mississippi",
"MO": "Missouri",
"MT": "Montana",
"NE": "Nebraska",
"NV": "Nevada",
"NH": "New Hampshire",
"NJ": "New Jersey",
"NM": "New Mexico",
"NY": "New York",
"NC": "North Carolina",
"ND": "North Dakota",
"OH": "Ohio",
"OK": "Oklahoma",
"OR": "Oregon",
"PA": "Pennsylvania",
"RI": "Rhode Island",
"SC": "South Carolina",
"SD": "South Dakota",
"TN": "Tennessee",
"TX": "Texas",
"UT": "Utah",
"VT": "Vermont",
"VA": "Virginia",
"WA": "Washington",
"WV": "West Virginia",
"WI": "Wisconsin",
"WY": "Wyoming"
}
if ret:
return a[state_name]
for key , val in a.items():
if val == state_name.title():
return key
else:
return state_name