Skip to content

Instantly share code, notes, and snippets.

@erickguan
Created January 28, 2013 10:52
Show Gist options
  • Select an option

  • Save erickguan/4654585 to your computer and use it in GitHub Desktop.

Select an option

Save erickguan/4654585 to your computer and use it in GitHub Desktop.
cim
import urllib.request
import urllib.parse
import http.cookiejar
cookiejar = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(
urllib.request.HTTPCookieProcessor(cookiejar))
dhu_url = "http://jw.dhu.edu.cn/dhu/login_zh.jsp"
login_data = urllib.parse.urlencode({'userName': '', 'userPwd': ''})
login_data = login_data.encode('utf-8')
target_url = "http://jw.dhu.edu.cn/dhu/student/selectcourse/seeselectedcourse.jsp"
opener.open(dhu_url, login_data)
html = opener.open(target_url)
print(html.read().decode("gbk"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment