<form action="https://auten.ub.edu/uauten.pl" method="post" name="login" id="login">
import urllib2
from urllib import urlencode
from cookielib import CookieJar
cookie_processor = urllib2.HTTPCookieProcessor(CookieJar())
opener = urllib2.build_opener(cookie_processor)
auth_data = {
# см. в firebug/еще где-то
}
opener.open('https://auten.ub.edu/uauten.pl', urlencode(auth_data))
opener
для навигации по сайту. >>> import httplib, urllib
>>> params = urllib.urlencode({'@number': 12524, 'type': 'issue', 'action': 'show'})
>>> headers = {"Content-type": "application/x-www-form-urlencoded",
... "Accept": "text/plain"}
>>> conn = httplib.HTTPConnection("bugs.python.org")
>>> conn.request("POST", "", params, headers)
>>> response = conn.getresponse()
>>> print response.status, response.reason
302 Found
>>> data = response.read()
>>> data
'Redirecting to http://bugs.python.org/issue12524'
>>> conn.close()
cookie_processor = urllib2.HTTPCookieProcessor(CookieJar())
opener = urllib2.build_opener(cookie_processor)
auth_data = {
'login': '*****',
'password': '******'
}
opener.open('https://feinaactiva.gencat.cat/web/guest/candidatelogin?p_p_id=loginCandidate&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_loginCandidate_struts_action=%2FloginCandidate%2Fauthentication', urlencode(auth_data))
req = opener.open('https://feinaactiva.gencat.cat/group/candidate/jobslocator?p_p_id=jobsLocator_WAR_psocwebjobslocator&p_p_lifecycle=1&p_p_state=maximized&p_p_mode=view&_jobsLocator_WAR_psocwebjobslocator_struts_action=%2Fjobslocator%2FjobsLocator&saveLastPath=0&_jobsLocator_WAR_psocwebjobslocator_forwardPath=search')
html = req.read()