python3 获取http请求的返回状态码
2021-02-08 09:19
标签:odi 请求 lang def log 状态 request import class python3 获取http请求的返回状态码 标签:odi 请求 lang def log 状态 request import class 原文地址:https://blog.51cto.com/liuxiaolan/2490018#!/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请求的返回状态码
文章链接:http://soscw.com/index.php/essay/52583.html