【发布时间】:2017-10-10 23:03:28
【问题描述】:
我正在尝试使用请求从 NPI API 中提取信息,但提取信息平均需要 20 多秒。如果我尝试通过我的网络浏览器访问它,只需不到一秒钟的时间。我对此很陌生,任何帮助将不胜感激。这是我的代码。
import json
import sys
import requests
url = "https://npiregistry.cms.hhs.gov/api/?number=&enumeration_type=&taxonomy_description=&first_name=&last_name=&organization_name=&address_purpose=&city=&state=&postal_code=10017&country_code=&limit=&skip="
htmlfile=requests.get(url)
data = htmlfile.json()
for i in data["results"]:
print(i)
【问题讨论】:
-
这真的很奇怪。刚才还在工作。我想我打错了。这是工作链接:npiregistry.cms.hhs.gov/api/…
-
对我来说 curl 和 python 大约需要 1.3 秒
-
curl 和 Requests 是不同的库吗?
-
它是使用该库构建的library and a command line utility。我稍后使用,不涉及python。
-
我不认为 python 3.6 支持 curl。请求真的比 curl 慢得多吗?我喜欢请求的易用性。
标签: python http python-requests python-3.6