为了账号安全,请及时绑定邮箱和手机立即绑定

python 循环提取 API 数据以迭代 URL

python 循环提取 API 数据以迭代 URL

梵蒂冈之花 2021-09-02 14:51:14
I'm trying to set up a for loop to pull in elected representatives' data for about 600,000 postal codes. 基本 URL 保持不变,唯一改变的部分是邮政编码。理想情况下,我想创建所有邮政编码的列表,然后使用 requests.get 提取列表中所有邮政编码的数据。我在下面想出了这个代码,但它只是为我的列表中的最后一个邮政编码提取数据。我不确定为什么会发生这种情况,我是一名 Python 初学者 - 所以任何帮助将不胜感激!#loop test postcodes = ['P0L1B0','P5A3P1', 'P5A3P2', 'P5A3P3']for i in range(len(postcodes)):   rr = requests.get('https://represent.opennorth.ca/postcodes/{}'.format(postcodes[i]))data1=json.loads(rr.text)data1
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 167 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号