Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - web access yields "503"

 
Thread Tools Search this Thread
Old 08-05-2009, 04:05 PM   #1
Default web access yields "503"


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/a.../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?u...oofa&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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
I cant access the MCP site T3M4N MCTS 1 03-18-2008 06:21 PM
Pix 515E Access List issue ally0000 Hardware 3 02-15-2008 01:34 PM
How To Access HTML elements in code behind??? nedums_b Software 1 02-07-2008 07:15 PM
Pix 515E Access ist issue ally0000 Hardware 0 01-12-2008 10:09 AM
Cannot access one URL Elke General Help Related Topics 1 12-02-2006 11:36 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46