[Python] How to reset a StackAPIError: 502, 'throttle_violation', 'too many requests from this...

Discussão em 'Python' iniciado por Stack, Dezembro 8, 2024.

  1. Stack

    Stack Membro Participativo

    I need to reset a StackAPIError: ('https://api.stackexchange.com/2.3/sites/?pagesize=1000&page=1&filter=!*L1*AY-85YllAr2)', 502, 'throttle_violation', 'too many requests from this IP, more requests available in 80678 seconds').

    I have tried different rate_limit settings and different time-delays before my fetches but still continue to get this error. I cannot continue to wait 24 hours for this error to clear to try another time delay setting to only get the error again. My question and answer fetches are shown below.

    SITE = StackAPI('stackoverflow')
    max_questions = 100


    try:
    time.sleep(random.uniform(4, 7)) # Wait between 4 and 7 seconds to avoid StackAPIError: 502, Throttle Violation, Too Many Requests
    questions = SITE.fetch('questions', tagged='visual-studio', sort='votes', pagesize=max_questions, page=1, filter='withbody', rate_limit=2)


    try:
    time.sleep(random.uniform(4, 7)) # Wait between 4 and 7 seconds to avoid StackAPIError: 502, Throttle Violation, Too Many Requests
    answer_data = SITE.fetch('answers/{ids}', ids=[accepted_answer_id], filter='withbody')


    ---------------------------------------------------------------------------
    StackAPIError Traceback (most recent call last)
    <ipython-input-11-d81d4cee1371> in <cell line: 2>()
    1 # Seed the faq_database
    ----> 2 scrape_faqs()

    2 frames
    /usr/local/lib/python3.10/dist-packages/stackapi/stackapi.py in fetch(self, endpoint, page, key, filter, **kwargs)
    211 code = response["error_name"]
    212 message = response["error_message"]
    --> 213 raise StackAPIError(self._previous_call, error, code, message)
    214 except KeyError:
    215 pass # This means there is no error

    StackAPIError: ('https://api.stackexchange.com/2.3/sites/?pagesize=1000&page=1&filter=%21%2AL1%2AAY-85YllAr2%29', 502, 'throttle_violation', 'too many requests from this IP, more requests available in 80678 seconds')

    Continue reading...

Compartilhe esta Página