Skip to main content
 首页 » 编程设计

python之试图从 URL 中提取 JSON 数据到 Jupyter 中

2025年05月04日23bjzhanghao

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

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

请您参考如下方法:

这是你想要的吗?

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, 
  ...