【发布时间】:2021-01-28 05:06:48
【问题描述】:
我们需要来自网站
from threading import Timer
import time
import requests
startlog = time.time()
image_url = "https://api.data.gov.sg/v1/transport/traffic-images"
tm = 0
while True:
tm += 1
r = requests.get(image_url) # create HTTP response object
with open(str(tm)+"trafficFile.json", 'wb') as f:
f.write(r.content)
print(tm)
time.sleep(20)
【问题讨论】:
-
你检查过输出是如何从那个 api 返回的吗?检查 r 的其他变量。
标签: python python-requests python-requests-html