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 8850067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:48:49+00:00 2026-06-14T12:48:49+00:00

I’m scraping a website with cookies. They provide multiple drop-down menus and I’m iterating

  • 0

I’m scraping a website with cookies. They provide multiple drop-down menus and I’m iterating through each option and re-capturing the session cookies with every request. The code runs just fine for a while, but I randomly get a 503 error.

My code inserts data into a PostgreSQL database, and to help emphasize the randomness of this error I want to share that I’ve received the 503 after inserting as few as 1200 entries (rows) and as many as 4200. There doesn’t seem to be any pattern to the raising of the this exception. I can’t make sense of it.

If it helps, here is a portion of my code:

# -*- coding: utf-8 -*-

import scrape_tools
import psycopg2
import psycopg2.extras
import urllib
import urllib2
import json
import cookielib
import time


tools = scrape_tools.tool_box()
db = tools.db_connect()
psycopg2.extras.register_hstore(db)
cursor = db.cursor(cursor_factory = psycopg2.extras.RealDictCursor)

cookiejar = cookielib.CookieJar()
opener = urllib2.build_opener(
    urllib2.HTTPRedirectHandler(),
    urllib2.HTTPHandler(debuglevel=0),
    urllib2.HTTPSHandler(debuglevel=0),
    urllib2.HTTPCookieProcessor(cookiejar),
)

url ='http://www.website.com/'
soup = tools.request(url)

type_select = soup('select',{'id':'type'})
for option_tag in type_select:
    select_option = option_tag('option')
    for option_contents in select_option:
        if 'Select' in option_contents.contents[0]:
            continue
        type = option_contents.contents[0]
        type_val = option_contents['value']
        print 'Type', type

        get_more_url = 'http://www.website.com/' + type_val
        request2 = urllib2.Request(get_more_url)
        fp2 = opener.open(request2)
        html2_object = fp2.read()
        json_result = json.loads(html2_object)

        for json_dict in json_result:
            for json_key in json_dict:
                if len(json_key) == 0:
                    continue
                more_data = json_dict[json_key]
                print '   ', more_data

               (---Out of courtesy, I'll stop here--)

(*Please note, scrape_tools is a custom module)

Am I missing something with cookie storage? Am I missing something obvious? I can’t seem to figure out why this is happening. I’ve ‘googled’, ‘stackoverflowed’, etc. for hours trying to find somebody having similar issues, but haven’t found anything.

I’ve also used selenium to scrape data in the past and have that in my pocket as a last resort, but this project is huge and I’d rather not have Firefox eating up memory on the server for a week.

  • 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-06-14T12:48:51+00:00Added an answer on June 14, 2026 at 12:48 pm

    HTTP status 503, “Service Unavailable”, means that for some reason the server wasn’t able to process your request–but it’s usually a transient error. If you wait a bit and retry the same request, it will probably work.

    You do need to be able to handle this kind of transient failure in large-scale scraping jobs, because the Internet is full of transient errors. Connections fail or are dropped all the time. A simple retry policy is usually all you need though.

    Status 503 could specifically mean that you’re requesting pages too quickly, though. If you don’t have a delay between page fetches, you should add one, for politeness’ sake.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I am using Paperclip to handle profile photo uploads in my app. They upload
I am trying to loop through a bunch of documents I have to put
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.