【问题标题】:Trying to extract JSON data from an URL into Jupyter?试图从 URL 中提取 JSON 数据到 Jupyter?
【发布时间】:2018-02-12 23:06:14
【问题描述】:

尝试从以下网站提取数据:

https://gbfs.fordgobike.com/gbfs/gbfs.json

【问题讨论】:

  • 过渡到 Python 3,你是说 IDE?你应该看看请求库。

标签: python json extract jupyter


【解决方案1】:

这是你想要的吗?

import requests

url = 'https://gbfs.fordgobike.com/gbfs/gbfs.json'
data = requests.get(url).json()

print(data)

可用的游乐设施数量,试试这个:

import requests

url = 'https://gbfs.fordgobike.com/gbfs/en/station_status.json'
data = requests.get(url).json()

d = {s['station_id']:s['num_bikes_available'] for s in data['data']['stations']}

print(d)

结果:

{'10': 28,
 '100': 14,
 '101': 8,
 '102': 22,
 '103': 0,
 '104': 0,
 '105': 5,
 '106': 1,
 '107': 14,
 '108': 1,
 '109': 2,
 '11': 16,
 '110': 10,
 '112': 13,
 '113': 5,
 '114': 9,
  ...

【讨论】:

  • 是的,我也在尝试增加每个站点的乘车次数。
  • 太棒了。谢谢你。我不知道正确的语法。感谢您的建议。
猜你喜欢
  • 2020-08-20
  • 1970-01-01
  • 1970-01-01
  • 2018-10-31
  • 1970-01-01
  • 2018-08-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多