logging into asp site with python
<p>I'm trying to log into <a href="https://www.surveymonkey.com/MyAccount_Login.aspx" rel="nofollow">https://www.surveymonkey.com/MyAccount_Login.aspx</a> using Python and I'm getting an error back. This is the code I'm using to log in:</p>

<pre><code>import urllib, urllib2, cookielib
username = '&lt;my user name&gt;'
password = '&lt;my password&gt;'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data=urllib.urlencode({'wc_Login1$txtUsername':username, 'wc_Login1$txtPassword':password})
opener.open('https://www.surveymonkey.com/MyAccount_Login.aspx', login_data)
</code></pre>

<p>At this point, I'm getting the following back:</p>

<pre><code>&lt;addinfourl at 43343112L whose fp = &lt;socket._fileobject object at 0x00000000028A4ED0&gt;&gt;
</code></pre>

<p>I believe I identified the username and password fields correctly as wc_Login1$txtUsername and wc_Login1$txtPassword using Opera's Dragonfly. </p>

<p>If I add the following to see if I've logged in correctly:</p>

<pre><code>resp=opener.open('http://www.surveymonkey.com/MySurveys.aspx')
print resp.read()
</code></pre>

<p>It appears that I'm still stuck on the login page.</p>

<pre><code>&lt;!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;title&gt;SurveyMonkey - Log in&lt;/title&gt;
</code></pre>

<p>Any thoughts? I've read that logging into asp pages is a pain using python, but this one kinda looked straightforward.</p>
