Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6917177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:41:50+00:00 2026-05-27T09:41:50+00:00

I’m having trouble using the urllib2.urlopen on a particular URL on GAE. When I

  • 0

I’m having trouble using the urllib2.urlopen on a particular URL on GAE. When I run the same code on using Eclipse, I’m able to retrieve the website data, but when I try it with a GAE implementation, I get ‘Status 500 Internal Server Error’.

On the ordinary Python app, I have the following code that works fine.

query2 = {'ORIGIN': 'LOS','DESTINATION':'ABV', 'DAY':'23',
          'MONTHYEAR': 'JAN2012', 'RDAY': '-1', 'RMONTHYER': '-1',
          'ADULTS': '1', 'KIDS': '0', 'INFANTS': '0', 'CURRENCY': 'NGN',
          'DIRECTION': 'SEARCH', 'AGENT': '111210135256.41.138.183.192.29025'}

encoded = urllib.urlencode(query2)
url3 = 'http://www.flyaero.com/cgi-bin/airkiosk/I7/171015'
request = urllib2.urlopen(url3, encoded)

print 'RESPONSE:', request
print 'URL     :', request.geturl()

headers = request.info()
print 'DATE    :', headers['date']
print 'HEADERS :'
print '---------'
print headers

data = request.read()
print 'LENGTH  :', len(data)
print 'DATA    :'
print '---------'
print data

This works just fine, but with GAE, it doesn’t. This is the GAE code:

class MainPage(webapp.RequestHandler):
    def get(self):      
        query = {'ORIGIN': 'LOS','DESTINATION':'ABV', 'DAY':'23',
                 'MONTHYEAR': 'JAN2012', 'RDAY': '-1', 'RMONTHYER': '-1',
                 'ADULTS': '1', 'KIDS': '0', 'INFANTS': '0', 'CURRENCY': 'NGN',
                 'DIRECTION': 'SEARCH', 'AGENT': '111210135256.41.138.183.192.29025'}

        urlkey = 'http://www.flyaero.com/cgi-bin/airkiosk/I7/181002i?AJ=2&LANG=EN'
        urlsearch = 'http://www.flyaero.com/cgi-bin/airkiosk/I7/171015'
        user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
        header = { 'User-Agent' : user_agent }

        try:
            request = urllib2.urlopen(urlkey)
            data = request.read()
            info = request.info()
        except urllib2.URLError, e:
            print 'error code: ', e

        print 'INFO:'
        print info  
        print ''        
        print 'Old key is: ' + query['AGENT']

        print 'Agent key is  ' + query['AGENT']
        encoded = urllib.urlencode(query)
        print 'encoded data', encoded
        print ''
        print 'web data'
        print''

        try:
            request2 = urllib2.urlopen(urlsearch, encoded)
            data2 = request2.read()
            info2 = request2.info()
        except urllib2.URLError, e:
            print 'error code: ', e

        print 'INFO:'
        print info2
        print ''
        print 'DATA: '
        print data

There are two calls to urllib2.urlopen. The first one works, but the second one returns error 500 and the try-except block doesn’t catch it.

this is the message printed out by the request.info() command

Status: 500 Internal Server Error
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 1662

I’m not on the develooper server, i’m developing with eclipse, and running from localhost on my system. The is the error message that appears on the brower and on eclipse console as well, this is the message:

    WARNING  2011-12-10 17:29:31,703 urlfetch_stub.py:405] Stripped prohibited headers from   URLFetch request: ['Host']
    WARNING  2011-12-10 17:29:33,075 urlfetch_stub.py:405] Stripped prohibited headers from      URLFetch request: ['Content-Length', 'Host']
    ERROR    2011-12-10 17:29:38,305 __init__.py:463] ApplicationError: 2 timed out
    <pre>Traceback (most recent call last):

  File &quot;C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\__init__.py&quot;, line 700, in __call__

handler.get(*groups)

  File &quot;C:\Users\TIOLUWA\Documents\CODES\Elipse\FlightShop\flightshop.py&quot;, line 124, in get

    request2 = urllib2.urlopen(urlsearch, encoded)

  File &quot;C:\python25\lib\urllib2.py&quot;, line 124, in urlopen

    return _opener.open(url, data)

  File &quot;C:\python25\lib\urllib2.py&quot;, line 381, in open

    response = self._open(req, data)

  File &quot;C:\python25\lib\urllib2.py&quot;, line 399, in _open
    '_open', req)

  File &quot;C:\python25\lib\urllib2.py&quot;, line 360, in _call_chain

    result = func(*args)

  File &quot;C:\python25\lib\urllib2.py&quot;, line 1107, in http_open

    return self.do_open(httplib.HTTPConnection, req)

  File &quot;C:\python25\lib\urllib2.py&quot;, line 1080, in do_open

    r = h.getresponse()

  File &quot;C:\Program Files (x86)\Google\google_appengine\google\appengine\dist\httplib.py&quot;, line 213, in getresponse

    self._allow_truncated, self._follow_redirects)

  File &quot;C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch.py&quot;, line 260, in fetch

    return rpc.get_result()

  File &quot;C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py&quot;, line 592, in get_result

    return self.__get_result_hook(self)

  File &quot;C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch.py&quot;, line 358, in _get_fetch_result

    raise DownloadError(str(err))

    DownloadError: ApplicationError: 2 timed out
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:41:50+00:00Added an answer on May 27, 2026 at 9:41 am

    As the exception indicates, it’s failing because the outgoing HTTP request timed out. Instead of using urllib2, use URLFetch directly, and pass the deadline argument to the fetch function with a longer deadline.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.