回答編集履歴

1

プログラム追記

2019/11/24 03:26

投稿

barobaro
barobaro

スコア1286

test CHANGED
@@ -7,3 +7,41 @@
7
7
 
8
8
 
9
9
  https://www.tokyometro.jp/library/common/operation/status.json
10
+
11
+
12
+
13
+ ```python
14
+
15
+ import requests
16
+
17
+ import json
18
+
19
+
20
+
21
+ url = "https://www.tokyometro.jp/library/common/operation/status.json"
22
+
23
+
24
+
25
+ r = requests.get(url)
26
+
27
+
28
+
29
+ r.raise_for_status()
30
+
31
+
32
+
33
+ # jsonpからjsonに変換
34
+
35
+ data_json = r.text.split("(", 1)[1].strip(")")
36
+
37
+
38
+
39
+ result = json.loads(data_json)
40
+
41
+
42
+
43
+ for line in result["jp"]["lines"]:
44
+
45
+ print(f"{line['line_name']}:{line['contents']}")
46
+
47
+ ```