Search code examples
pythonpython-3.xpython-requests

Different Response codes for different sites


So I am making a get request to many websites, but there is a huge problem.

Each website have their own specific code and it is not always 200, for some websites it is 403, 525, etc.

So, how do I know which website will give what response code or do I have to manually save what response code a website will give to the visitor. I have tried to open the network in the developer option but can't understand what is going on.

I have a Json which stores the name and web address of the website, so should I add another key for working_response_code or is there a way to correct the code.

Tried: network in developer option expecting: something that works [an automated result (optional)]


Solution

  • Those codes are actually a defined standard that most of website respects, you can find a list here : https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

    Each one has a different meaning, in your case

    • 200 is success, the request has succeed
    • 403 is not authorized

    You can get the status code with by accessing the status_code property of the response object