如何优雅地排人才公寓

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
import requests
from bs4 import BeautifulSoup
import datetime

start_date = datetime.date(2018, 6, 6)
start_rank = 866

cookies = {
'ASP.NET_SessionId': 'obe4o1esws0xutvslbbapc55',
'safedog-flow-item': '',
}

headers = {
'Connection': 'keep-alive',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Referer': 'https://rcgy.zjhui.net/',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh',
}

params = (
('flag', '0'),
('userName', '13122358292'),
('passWord', 'MzAyMDI4MnpqeWQ='),
('md5', '08dcb32a31936c855b5f8f5c21f5b957'),
)

response = requests.get('https://rcgy.zjhui.net/Login.aspx', headers=headers, params=params, cookies=cookies)

headers = {
'Connection': 'keep-alive',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Referer': 'https://rcgy.zjhui.net/System/ApplyRecord.aspx',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh',
}

response = requests.get('https://rcgy.zjhui.net/System/WaitingRecord.aspx', headers=headers, cookies=cookies)

soup = BeautifulSoup(response.content, features="lxml")
rank = soup.find(id='ctl00_ctl00_ctl00_main_main_main_rptPtApplyRecord_ctl00_labPageRank').string
rank = int(rank)

today = datetime.date.today()
remain_days = float(rank) * (today - start_date).days / (start_rank - rank)
remain_days = int(remain_days)
check_in_date = today + datetime.timedelta(days=remain_days)

print "rank:\t", rank
print "days remaining:\t", remain_days
print "check in date:\t", check_in_date