def login(username, password):
# Cookie Jar
cj = cookiejar.CookieJar()
s = requests.Session()
s.cookies = cj
br = mechanicalsoup.StatefulBrowser(soup_config={'features': 'lxml'}, session=s)
login_url = "http://cyclebabac.com/wp-login.php"
# Perform the actual login
br.open(login_url)
br.select_form('#loginform')
br['log'] = str(username)
br['pwd'] = str(password)
br.submit_selected()
return br
评论列表
文章目录