usr bin env python coding utf-8 login passw import urllib import httpl

 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
login = ''
passw = ''
import urllib
import httplib
import re
import sys
print "==================== 1 ===================="
params = urllib.urlencode({'_stateParam': '',
'_forwardName': '',
'_resetBreadCrumbs': '',
'_expandStatus': '',
'userName': login,
'password': passw,
'ecareAction': 'login'})
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
conn = httplib.HTTPSConnection('uslugi.beeline.ru')
conn.request('POST', '/loginPage.do', params, headers)
response = conn.getresponse()
print response.status, response.reason
cookies = response.getheader('set-cookie')
sid = re.compile(ur"(?:JSESSIONID=)(.+?)(?:;)").findall(cookies)[0]
alt = re.compile(ur"(?:AlteonP=)(.+?)(?:;)").findall(cookies)[0]
#print response.getheaders()
#print unicode(response.read(), 'cp1251')
conn.close()
if sid == '' or alt == '':
sys.exit(1)
print "==================== 2 ===================="
head = {"Cookie": "JSESSIONID=%s; AlteonP=%s" % (sid, alt)}
conn = httplib.HTTPSConnection('uslugi.beeline.ru')
conn.request('GET', '/OnLoadSubscriberProfileFilterAction.do', headers=head)
response = conn.getresponse()
print response.status, response.reason
if response.status != 200:
sys.exit(2)
#print response.getheaders()
#print unicode(response.read(), 'cp1251')
conn.close()
print "==================== 3 ===================="
params = urllib.urlencode({
'_stateParam': 'Tree:orgRepl.selected=0;breadCrumbs.breadCrumbDO1=10_;hierarchyTree:orgRepl.effectiveDate=1224433887592;hierarchyTree:orgRepl.pointLogicalId=0;SubscriberService.subscriberListtableSelections=9_;eCareLocale.currentLocale=ru_RU__Russian;breadCrumbs.breadCrumbsSize=1;multi-level:menu.pointLogicalId=4;hierarchies:hierarchiesRepl1.pointLogicalId=1',
'_forwardName': '',
'_resetBreadCrumbs': '',
'_expandStatus': '',
'ctrla': 'subscriberListExt=CellClick=viewLinkStr=%s ' % login,
'status.code': 'G',
'subscriberNumber': login,
'pricePlan': '',
'subscriberListExtExportVar': '',
'ctrlvcol%3Dcheckbox%3Bctrl%3DsubscriberListExt%3Brow%3D' + login + '+%3Bsel%3Dmultiple%3Btype%3Dcb': 'on'})
headers = {'Content-Type': 'application/x-www-form-urlencoded',
"Cookie": "JSESSIONID=%s; AlteonP=%s" % (sid, alt)}
conn = httplib.HTTPSConnection('uslugi.beeline.ru')
conn.request('POST', '/SubscriberProfileFilterSwitchingAction.do', params, headers)
response = conn.getresponse()
print response.status, response.reason
if response.status != 200:
sys.exit(3)
data = unicode(response.read(), 'cp1251')
#print data
conn.close()
print "==========================================="
result = re.compile(ur"(?:Основной баланс.+?)(\d+,\d+)").findall(data)
if len(result) == 0:
sys.exit(4)
else:
print u"Баланс:", result[0]