forked from Boris-code/feapder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_params.py
More file actions
51 lines (40 loc) · 1.08 KB
/
create_params.py
File metadata and controls
51 lines (40 loc) · 1.08 KB
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
# -*- coding: utf-8 -*-
"""
Created on 2021/4/25 10:22 上午
---------
@summary: 将浏览器的cookie转为request的cookie
---------
@author: Boris
@email: boris_liu@foxmail.com
"""
import sys
from feapder.utils.tools import dumps_json
class CreateParams:
def get_data(self):
"""
@summary: 从控制台读取多行
---------
---------
@result:
"""
print("请输入请求地址")
data = []
while True:
line = sys.stdin.readline().strip()
if not line:
break
data.append(line)
return "".join(data)
def get_params(self, url):
params_json = {}
params = url.split("?")[-1].split("&")
for param in params:
key_value = param.split("=", 1)
params_json[key_value[0]] = key_value[1]
return params_json
def create(self):
data = self.get_data()
params = self.get_params(data)
url = data.split("?")[0]
print(f'url = "{url}"')
print(f"params = {dumps_json(params)}")