3

I am using twitch api (twitch-python and python-twitch-client)to scrape twitch.

I am not sure how should I manage these httperrors as I am not using urllib.request.

    game = []

    for a in lis[68:]:
        b = client.videos.get_by_id(a).game

        try:


            game.append(b)
        except Exception as e:
            print(type(e))

This error still arises even i use the except: HTTPError: 404 Client Error: Not Found for url: https://api.twitch.tv/kraken/videos/420146641

frifin
  • 109
  • 5
  • It might not be a class under `HTTPError`. Why don't you catch all exceptions first then print out the type of the exception? – absolutelydevastated Jul 04 '19 at 05:36
  • Thanks for your response. Because the error message says it is HTTPError, and even when I try to catch all the error with ``` except error``` it still does not work – frifin Jul 04 '19 at 05:42
  • What you need to do is `except Exception as e` then inside the clause do `print(type(e))` to check the type. If it's not going into the clause then it's clearly not an `HTTPError`. – absolutelydevastated Jul 04 '19 at 05:44

1 Answers1

1

Okay, I think I know where the issue lies. You're not wrapping the right code inside your try clause. It's unlikely that .append raises an error, so the error probably occurred while you were assigning b to the output of some error-throwing function. Move the first line of your code after the for-loop into the try block.

absolutelydevastated
  • 1,657
  • 1
  • 11
  • 28