回答編集履歴
2
些細
answer
CHANGED
@@ -6,12 +6,12 @@
|
|
6
6
|
|
7
7
|
使っているライブラリの公式ドキュメントを読みましょう。HTTPのステータスコードを理解しましょう。
|
8
8
|
|
9
|
-
[http://docs.python-requests.org/en/master/api/
|
9
|
+
[http://docs.python-requests.org/en/master/api/#requests.Response.ok](http://docs.python-requests.org/en/master/api/#requests.Response.ok)
|
10
10
|
|
11
11
|
(追記)
|
12
12
|
すみません。リンクに This is not a check to see if the response code is 200 OK. と書いてありますね。status_code をチェックしてください。
|
13
13
|
|
14
|
-
[http://docs.python-requests.org/en/master/api/
|
14
|
+
[http://docs.python-requests.org/en/master/api/#requests.Response.status_code](http://docs.python-requests.org/en/master/api/#requests.Response.status_code)
|
15
15
|
|
16
16
|
こちらですね。
|
17
17
|
|
1
status_codeのチェックを書き直しました。
answer
CHANGED
@@ -8,12 +8,20 @@
|
|
8
8
|
|
9
9
|
[http://docs.python-requests.org/en/master/api/?highlight=ok#requests.Response.ok](http://docs.python-requests.org/en/master/api/?highlight=ok#requests.Response.ok)
|
10
10
|
|
11
|
+
(追記)
|
12
|
+
すみません。リンクに This is not a check to see if the response code is 200 OK. と書いてありますね。status_code をチェックしてください。
|
13
|
+
|
14
|
+
[http://docs.python-requests.org/en/master/api/?highlight=ok#requests.Response.status_code](http://docs.python-requests.org/en/master/api/?highlight=ok#requests.Response.status_code)
|
15
|
+
|
16
|
+
こちらですね。
|
17
|
+
|
18
|
+
|
11
19
|
----
|
12
20
|
|
13
21
|
`response = requests.get(url, auth = auth)`の直後でreponseのステータスとエラーコードの確認をしましょう。
|
14
22
|
例えば
|
15
23
|
```python
|
16
|
-
if response.ok:
|
24
|
+
if response.status_code == requests.codes.ok:
|
17
25
|
# ここは正常なケース
|
18
26
|
pass
|
19
27
|
else:
|