forked from daidaojianke/jd_py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjd_init.py
100 lines (84 loc) · 1.94 KB
/
jd_init.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
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
# @Time : 2021/8/2 11:32 上午
# @File : jd_init.py
# @Project : jd_scripts
# @Desc : 装饰器定义
from urllib.parse import unquote
def jd_init(cls):
"""
:param cls:
:return:
"""
def init(self, **kwargs):
"""
初始化方法
:param self:
:param kwargs:
:return:
"""
pt_pin = kwargs.get('pt_pin')
pt_key = kwargs.get('pt_key')
if not pt_pin or not pt_key:
raise ValueError('Invalid Parameter!')
self._account = kwargs.get('account', None)
if not self._account:
self._account = unquote(pt_pin)
self._cookies = { # cookies
'pt_pin': pt_pin,
'pt_key': pt_key,
}
self._sort = kwargs.get('sort', 1)
self._message = ''
@property
def sort(self):
return self._sort
@sort.setter
def sort(self, sort):
self._sort = sort
@property
def message(self):
return self._message
@message.setter
def message(self, message):
self._message = message
@property
def cookies(self):
"""
返回cookies
:param self:
:return:
"""
return self._cookies
@cookies.setter
def cookies(self, cookies):
"""
设置cookies
:param self:
:param cookies:
:return:
"""
self._cookies = cookies
@property
def account(self):
"""
返回京东账号
:param self:
:return:
"""
return self._account
@account.setter
def account(self, account):
"""
设置账号
:param self:
:param account:
:return:
"""
self._account = account
cls.message = message
cls.account = account
cls.cookies = cookies
cls.sort = sort
cls.__init__ = init
return cls