Я должен был сделать эту точную вещь сам недавно. Мне только были нужны классы из стандартной библиотеки. Вот выборка от моего кода:
from urllib import urlencode
from urllib2 import urlopen, Request
# encode my POST parameters for the login page
login_qs = urlencode( [("username",USERNAME), ("password",PASSWORD)] )
# extract my session id by loading a page from the site
set_cookie = urlopen(URL_BASE).headers.getheader("Set-Cookie")
sess_id = set_cookie[set_cookie.index("=")+1:set_cookie.index(";")]
# construct headers dictionary using the session id
headers = {"Cookie": "session_id="+sess_id}
# perform login and make sure it worked
if "Announcements:" not in urlopen(Request(URL_BASE+"login",headers=headers), login_qs).read():
print "Didn't log in properly"
exit(1)
# here's the function I used after this for loading pages
def download(page=""):
return urlopen(Request(URL_BASE+page, headers=headers)).read()
# for example:
print download(URL_BASE + "config")
Решение состоит в том, чтобы сделать Visibility = "Collapsed" для содержимого всплывающего окна вместо закрытия всплывающего окна, но это немного взломано.