Note that there are some explanatory texts on larger screens.

plurals
  1. POurllib2 basic authentication oddites
    text
    copied!<p>I'm slamming my head against the wall with this one. I've been trying every example, reading every last bit I can find online about basic http authorization with urllib2, but I can not figure out what is causing my specific error. </p> <p>Adding to the frustration is that the code works for one page, and yet not for another. logging into www.mysite.com/adm goes absolutely smooth. It authenticates no problem. Yet if I change the address to 'http://mysite.com/adm/items.php?n=201105&amp;c=200' I receive this error:</p> <pre><code>&lt;h4 align="center" class="teal"&gt;Add/Edit Items&lt;/h4&gt; &lt;p&gt;&lt;strong&gt;Client:&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Event:&lt;/strong&gt; &lt;/p&gt;&lt;p class="error"&gt;Not enough information to complete this task&lt;/p&gt; &lt;p class="error"&gt;This is a fatal error so I am exiting now.&lt;/p&gt; </code></pre> <p>Searching google has lead to zero information on this error. </p> <p>The adm is a frame set page, I'm not sure if that's relevant at all. </p> <p>Here is the current code:</p> <pre><code>import urllib2, urllib import sys import re import base64 from urlparse import urlparse theurl = 'http://xxxxxmedia.com/adm/items.php?n=201105&amp;c=200' username = 'XXXX' password = 'XXXX' passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, theurl,username,password) authhandler = urllib2.HTTPBasicAuthHandler(passman) opener = urllib2.build_opener(authhandler) urllib2.install_opener(opener) pagehandle = urllib2.urlopen(theurl) url = 'http://xxxxxxxmedia.com/adm/items.php?n=201105&amp;c=200' values = {'AvAudioCD': 1, 'AvAudioCDDiscount': 00, 'AvAudioCDPrice': 50, 'ProductName': 'python test', 'frmSubmit': 'Submit' } #opener2 = urllib2.build_opener(urllib2.HTTPCookieProcessor()) data = urllib.urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) </code></pre> <p>This is just one of the many versions I've tried. I've followed every example from Urllib2 Missing Manual but still receive the same error. </p> <p>Can anyone point to what I'm doing wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload