web access yields "503"

Discussion in 'Python' started by roger_lynx, Aug 5, 2009.

  1. roger_lynx

    roger_lynx Guest

    Hi, I am porting a simple code from Perl, the website asks for
    usr/pwd and the server's side Perl script makes a temp ftp dir
    for a file upload.

    The original Perl script connects okay, does its job. The same URL
    stuffed into FF3 performs the same way.
    My Python script I am sweating over for past four days (noob!) gets
    consistently "503", even with user agent set to:
    Mozilla/5.0 (Windows;U; Windows NT 5.1; it; rv:1.8.1.11)Gecko/20071127 Firefox/2.0.0.11.

    Snippets of relevant code below, heavily copied from this author:
    http://www.voidspace.org.uk/python/articles/urllib2.shtml

    Please, help me understand how this same code lets me log in into my
    router usr/pwd running .asp, but this !@#$% perl script returns to me
    w/503 c*ap?
    Thank you.

    Do I need to set any proxy?
    The server is on intranet and the FF3 is
    set to proxy.
    The original Perl script did not use any proxy setting!
    LWP::

    <pre>

    url = http://bad_example.com/ftpsetup.pl?username=boofa&nodeid=42
    #########################################################
    # create a password manager
    password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
    # Add the username and password.
    # If we knew the realm, we could use it instead of ``None``.
    password_mgr.add_password(None, url, uid, pcode)
    handler = urllib2.HTTPBasicAuthHandler(password_mgr)
    class Mopener(URLopener): version = "Mozilla/5.0 (Windows; U;
    Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"

    opener = Mopener()

    # create "opener" (OpenerDirector instance)

    opener = urllib2.build_opener(handler)
    opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows; U;
    Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11')]

    opener.version = "Mozilla/5.0 (Windows; U;
    Windows NT 5.1; it; rv:
    1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"

    print opener.version
    # timeout in seconds
    timeout = 10
    socket.setdefaulttimeout(timeout)

    # Install the opener all calls to urllib2.urlopen use our opener.
    urllib2.install_opener(opener)

    try:
    response = opener.open(url)
    # "http://www.useragent.org/" tested okay!!!
    print"ok = 1"
    except:
    print "error 1"
    #####################################################################################

    output from the above:

    Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/
    20071127 Firefox/2.0.0.11
    error 1
    Error code: 503
    ('Service Unavailable', 'The server cannot process the request due to
    a high load')
    </pre>
    roger_lynx, Aug 5, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGFz?=

    503 This mail server requires authentication

    =?Utf-8?B?RGFz?=, Sep 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    3,235
    =?Utf-8?B?RGFz?=
    Sep 30, 2004
  2. =?Utf-8?B?VG9tYXMgS2VwaWM=?=

    ERROR: 'HTTP/1.0 503 Service Unavailable'

    =?Utf-8?B?VG9tYXMgS2VwaWM=?=, Apr 2, 2005, in forum: ASP .Net
    Replies:
    11
    Views:
    13,746
    =?Utf-8?B?VG9tYXMgS2VwaWM=?=
    Apr 5, 2005
  3. Rog

    http access produces 503

    Rog, Aug 5, 2009, in forum: Python
    Replies:
    1
    Views:
    437
    Piet van Oostrum
    Aug 5, 2009
  4. HBrothers

    Web Service Returns 503 Error

    HBrothers, Sep 29, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    215
    HBrothers
    Sep 29, 2004
  5. x1
    Replies:
    11
    Views:
    263
Loading...

Share This Page