如何使用Python的请求模块“登录”到网站?
from pyquery import PyQueryimport requests url = 'http://www.locationary.com/home/index2.jsp'
ck = {'inUserName': 'USERNAME/EMAIL', 'inUserPass': 'PASSWORD'}r = requests.post(url, cookies=ck)content = r.text q = PyQuery(content)title = q("title").text()print title
</td><td><img src="http://www.locationary.com/img/LocationaryImgs/icons/txt_email.gif"> </td><td><input class="Data_Entry_Field_Login" type="text" name="inUserName" id="inUserName" size="25"></td><td><img src="http://www.locationary.com/img/LocationaryImgs/icons/txt_password.gif"> </td><td><input class="Data_Entry_Field_Login" type="password" name="inUserPass" id="inUserPass"></td>
慕尼黑5688855
相关分类