1

我正在通过我的浏览器发送以下请求

https://www.overpass-api.de/api/interpreter?data=[out:json];area[name=Nicaragua];(node[aeroway=aerodrome][aeroway=aerodrome](area);way[aeroway=aerodrome][aeroway=aerodrome](area);>;relation[aeroway=aerodrome][aeroway=aerodrome](area);>>;);out meta;

如果您尝试,它将返回一个有效的 json。

但是,如果我尝试通过代码中的 curlpp 驱动程序发送它,我会收到一个“错误请求”页面作为回报。代码如下:


#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>

int main() {
    std::string url = "https://www.overpass-api.de/api/interpreter?data= 
    [out:json];area[name=Nicaragua];(node[aeroway=aerodrome] 
    [aeroway=aerodrome](area);way[aeroway=aerodrome][aeroway=aerodrome] 
    (area);>;relation[aeroway=aerodrome][aeroway=aerodrome](area);>>;);out 
    meta;";
    std::cout << url << std::endl;
    curlpp::Cleanup cleaner;
    curlpp::Easy request;

    request.setOpt(new curlpp::options::Url(url));

    std::cout << request << std::endl;


    std::cout << curlpp::options::Url(url) << std::endl;
    return 0;
}

但是,如果您尝试使用任何其他网址,它会起作用... curl 是否只接受某种字符串格式?

4

0 回答 0