python-requests - 最近使用 Overpass API 的 ConnectionErrors
问题描述
最近,当我尝试访问 Overpass API 时,我一直在从 Python 请求中弹出 ConnectionErrors。查询如下:
overpass_urls = ["https://overpass.kumi.systems/api/interpreter", "https://lz4.overpass-api.de/api/interpreter",
"https://overpass.kumi.systems/api/interpreter"]
for i, url in enumerate(overpass_urls):
resp, data = query_request(overpass_urls[i], osm_tag, bounds)
if resp.status_code == 200:
break
else:
print(resp.status_code)
def query_request(overpass_url, osm_tag, bounds):
query = """
[out:json]
[timeout:30]
[bbox:{s_bound}, {w_bound}, {n_bound}, {e_bound}];
(
node[{tag}];
way[{tag}];
rel[{tag}];
);
out center body;
>;
out center qt;
""".format(tag=osm_tag,
s_bound=bounds[0], w_bound=bounds[1], n_bound=bounds[2], e_bound=bounds[3])
resp = requests.get(overpass_url, params={'data': query}, verify=False)
data = resp.json()
return resp, data
('连接中止。', FileNotFoundError(2, '没有这样的文件或目录'))
这是不断吐出的错误,以及来自 Python Requests 模块的 ConnectionError。这只是在最近几周才开始发生,我想知道 Overpass API 是否发生了变化,但我在变更日志中找不到任何内容。
解决方案
推荐阅读
- php - 根据 Woocommerce 中的特定产品属性值更改购物车商品价格
- android - 手机锁定时无法在 onMessageReceived 上接收数据负载消息
- jquery - 如何分配一个类只与其他类一起运行?
- delphi - 如何在 Delphi 10.2 中使用接口方法作为方法类型的参数
- php - PHP PDO类查询方法在没有找到记录时返回true或false
- javafx - JavaFX:选择空白项后再次显示提示文本
- javascript - 如何以 Javascript 数组为中心获取图像
- javascript - 仅在后跟字符时应用正则表达式
- javascript - react native 如何只允许一个链接在 IOS 的 webview 中运行?
- python - Tensorflow - 有条件地根据其占位符值之一创建操作