Python Network Programming
by Abhishek Ratan, Eric Chou, Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker
How it works...
We have used Python's cookielib and set up a CookieJar and cj. The login data has been encoded using urllib.urlencode. urllib2 has a build_opener() method, which takes the predefined CookieJar with an instance of HTTPCookieProcessor() and returns a URL opener. We call this opener twice: once for the login page and once for the home page of the website. It seems that only one cookie, bb_session, was set with the set-cookie directive present in the page header. More information about cookielib can be found on the official Python documentation site at http://docs.python.org/2/library/cookielib.html. Cookielib has been replaced by http.cookiejar in Python 3. You may find more information on this at https://docs.python.org/3/library/http.cookiejar.html ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access