-
Notifications
You must be signed in to change notification settings - Fork 32
/
main.py
executable file
·75 lines (60 loc) · 1.89 KB
/
main.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
# -*- coding: utf-8 -*-
from faker import Factory
import requests
import random
fake = Factory.create()
def headers():
return {
'X-Forwarded-For': ip()
}
def ip():
return '.'.join([str(x) for x in [random.randint(1, 254),
random.randint(1, 254),
random.randint(1, 254),
random.randint(1, 254)]])
def vote():
username = fake.user_name()
email = fake.email()
real_name = Factory.create(locale='zh_CN').name()
s = requests.session()
s.headers.update(headers())
register_data = {
"userName": username,
"email": email,
"password": "123456",
"password1": "123456",
"realName": real_name,
"province": "北京市",
"job": "IT|互联网|通信",
"mobile": "",
"address": "",
}
register_data = {
'_ZVING_METHOD': 'Register.doRegister',
'_ZVING_URL': '%2Fregister',
'_ZVING_DATA': str(register_data),
'_ZVING_DATA_FORMAT': 'json',
}
url = "http://zqyj.chinalaw.gov.cn/ajax/invoke"
r1 = s.post(url, data=register_data)
print(r1.status_code, r1.text)
vote_data = {
'_ZVING_METHOD': 'SupportOppose.voteOppose',
'_ZVING_URL': '%2FdraftDetail',
'_ZVING_DATA': '{"ID":"45114"}',
'_ZVING_DATA_FORMAT': 'json',
}
r2 = s.post(url, data=vote_data, cookies=r1.cookies)
print(r2.status_code, r2.text)
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--count", help="vote how many times", default=10, type=int)
parser.add_argument("--forever", help="vote forever", action='store_true')
args = parser.parse_args()
if args.forever:
while True:
vote()
else:
for i in range(args.count):
vote()