python3 获取http请求的返回状态码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python3 获取http请求的返回状态码相关的知识,希望对你有一定的参考价值。

#!/bin/env python # -*- coding: UTF-8 -*- # example: python3 http_status.py https://blog.51cto.com/liuxiaolan/2488619 import requests import sys def http_status(arg): try: html = requests.get(arg) code = html.status_code print(code) except: print(1) sys.exit(0) if __name__ == "__main__": code = sys.argv[1] http_status(code)

以上是关于python3 获取http请求的返回状态码的主要内容,如果未能解决你的问题,请参考以下文章