!user/bin/env python3
-- coding: utf-8 --
import sys
import mechanize
import cookielib
br = mechanize.Browser()
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
br.open('http://stu.szu.edu.cn:8080/account/signin/')
br.select_form(nr=0)
br.form['username'] = ['92']
br.form['password'] = 'office789'
response = br.submit() #上面几步是模拟登陆以获得cookies
print response.read()
reload(sys)
sys.setdefaultencoding('utf-8')
br.open('http://stu.szu.edu.cn:8080/meeting_room/apply/')
br.select_form(nr=0)
以下开始都是申请表的内容
br.form['meeting_topic'] = 'HYZT'
br.form['applicant_name'] = 'SQRXM'
br.form['applicant_phone_number'] = '00123456'
br.form['applicant_stu_id'] = '2015300025'
br.form['applicant_college'] = 'SQRXY'
br.form["place"] = ["石头坞一楼会议室"]
br.form["date_month"] = ["8"]
br.form["date_day"] = ["24"]
br.form["date_year"] = ["2018"]
br.form["time"] = ["8点-8点30分","8点30分-9点"]
form.set_value(["8点-8点30分","8点30分-9点"], name="time")
br.form['meeting_summary'] = 'meeting_summary'
br.form['remarks'] = 'remarks'
以上都是申请表的内容
response = br.submit()
print response.read()