Skip to content

Commit f90a134

Browse files
SignUp.py
1 parent 86f685f commit f90a134

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Requests/SignUp.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import requests
2+
import string
3+
import random
4+
from lxml import html
5+
import time
6+
7+
postUrl = "http://127.0.0.1:8000/register"
8+
9+
10+
for _ in range(2):
11+
page = requests.get(postUrl)
12+
tree = html.fromstring(page.content)
13+
token = tree.xpath('//input[@name = "_token"]/@value')
14+
print(token)
15+
16+
username = ''.join(random.choice(string.ascii_letters) for _ in range(8))
17+
formData = {
18+
'_token' : token,
19+
'name' : username ,
20+
'email' : username + '@gmail.com',
21+
'password' : username,
22+
'password_confirmation' : username
23+
}
24+
print(formData)
25+
r= requests.post(postUrl, allow_redirects=False , data = formData)
26+
print(r)
27+
time.sleep(5)
28+
29+
30+
31+
# username = ''.join(random.choice(string.ascii_letters) for _ in range(8))
32+
# print(username)
33+
# page = requests.get(postUrl)
34+
# tree = html.fromstring(page.content)
35+
# tree = tree.xpath('//input[@name = "_token"]/@value')
36+
# print(tree)
37+
# <meta name="csrf-token" content="B9A4QQICIGZVzJ1Ay2sqTOlNa2McFgezG31dUFWT">
38+
#<form class="form-horizontal" method="POST" action="http://127.0.0.1:8000/register"><input type="hidden" name="_token" value="P4JaIeqSmxO821sVlFQKWTKwtWsTvicio7UCNAWT">

0 commit comments

Comments
 (0)