SoapHttpClientProtocol.ReadResponse – The request failed with HTTP status 401: Unauthorized

I have an ASP.NET (v2.0) web application that uses a reference to a SQL Server Reporting Services 208 R2 instance (using the ReportService2010.asmx service endpoint). The web application is hosted on ServerA and the Reporting Services instance is hosted on ServerB. ServerA is running Windows Server 2003 (IIS6) and ServerB is running Windows Server 2008 R2.

How to use Python to login to a webpage and retrieve cookies for later usage?

I want to download and parse webpage using python, but to access it I need a couple of cookies set. Therefore I need to login over https to the webpage first. The login moment involves sending two POST params (username, password) to /login.php. During the login request I want to retrieve the cookies from the response header and store them so I can use them in the request to download the webpage /data.php.