forked from Rockyzsu/stock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrealtime_kzz_price.py
More file actions
89 lines (78 loc) · 2.51 KB
/
realtime_kzz_price.py
File metadata and controls
89 lines (78 loc) · 2.51 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
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
# -*-coding=utf-8-*-
# @Time : 2020/1/20 10:54
# @File : realtime_price.py
import pypinyin
import requests
session = requests.Session()
cookies = {
'auto_reload': 'true',
'kbzw_r_uname': '%E9%87%8F%E5%8C%96%E8%87%AA%E7%94%B1%E4%B9%8B%E8%B7%AF',
'kbz_newcookie': '1',
'kbzw__Session': '1kmak8h8v6pscf5brjllb9hfk3',
'Hm_lvt_164fe01b1433a19b507595a43bf58262': '1578275141,1578879529',
'Hm_lpvt_164fe01b1433a19b507595a43bf58262': '1579488732',
}
headers = {
'Sec-Fetch-Mode': 'cors',
'Origin': 'https://www.jisilu.cn',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh,en;q=0.9,en-US;q=0.8',
'X-Requested-With': 'XMLHttpRequest',
'Connection': 'keep-alive',
'Pragma': 'no-cache',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Cache-Control': 'no-cache',
'Referer': 'https://www.jisilu.cn/data/cbnew/',
'Sec-Fetch-Site': 'same-origin',
}
params = (
('___jsl', 'LST___t=1579488785838'),
)
data = {
'fprice': '',
'tprice': '',
'volume': '',
'svolume': '',
'premium_rt': '',
'ytm_rt': '',
'rating_cd': '',
'is_search': 'Y',
'btype': '',
'listed': 'Y',
'sw_cd': '',
'bond_ids': '',
'rp': '50'
}
while 1:
name = input('input name => ')
if name=='q':
print('退出')
break
try:
response = session.post('https://www.jisilu.cn/data/cbnew/cb_list/', headers=headers, params=params, cookies=cookies, data=data,timeout=3)
except Exception as e:
print(e)
continue
ret = response.json()
for body_dict in ret.get('rows',[]):
# print(item)
item=body_dict.get('cell',{})
bond_nm = item.get('bond_nm','').strip()
a=pypinyin.pinyin(bond_nm, style=pypinyin.FIRST_LETTER)
b = []
for i in range(len(a)):
b.append(str(a[i][0]).lower())
c = ''.join(b)
if name == c:
full_price=item.get('full_price')
remium_rt=item.get('premium_rt')
increase_rt=item.get('increase_rt')
sincrease_rt=item.get('sincrease_rt')
print('name ==>',bond_nm.replace('转债',''))
print('price ==>',full_price)
print('pecent ==>',increase_rt)
print('yjl ==>',remium_rt)
print('正骨percent ==>',sincrease_rt)
print('\n')