After making some small games, I began to slowly realize that typing code is a physical job, and you can get through it slowly. In the past few days, I have had the urge to write a small program that simulates logging into the academic administration system to calculate GPA. However, I didn’t have any experience in network programming before, so I took advantage of the four-day holiday after the midterm exam to fill in the gaps bit by bit.Recently I have an inexplicable fondness for the Java language. I originally planned to use Java for development, but it turns out that Java seems to be more troublesome thanpython
in terms of network programming. In addition, one method of Java was used incorrectly, which caused the school's academic administration system to mistakenly think that I was performing SQL injection and blocked my IP. (...) From then on, I made up my mind to write in python.
# 保存cookie cj = cookielib.LWPCookieJar() cookie_support = urllib2.HTTPCookieProcessor(cj) opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler) urllib2.install_opener(opener)
From the analysis of the above two pictures, we can get the real requested web page: 121.251.19.29/pass.asp
url = '121.251.19.29/pass.asp' h = urllib2.urlopen(url) info = {'UserStyle': 'student', 'user': user, 'password': psw} info = urllib.urlencode(info) req = urllib2.Request(url, info) urllib2.urlopen(req)
Open the request webpage and read the source code of the score page
req = urllib2.Request('121.251.19.29/student/asp/Select_Success.asp') resData = urllib2.urlopen(req) res = resData.read() # 读取成绩页面
tag = re.compile('?[^>]*>') s = re.sub(tag, '', res) # 过滤标签 tmp = s.split()
Finally, I was a little clever. After the account is successfully logged in, the account password will be sent to My email
1.
PHP collection and simulated login forum applet_PHP tutorial Instructions for creating the login process for WeChat mini program development Form verification example tutorial for mini program development Solution and Optimization of Your WeChat Mini ProgramThe above is the detailed content of A small program that simulates logging into the academic administration system to calculate GPA. For more information, please follow other related articles on the PHP Chinese website!