0

尝试使用 Vertx WebClient从此url下载文件但不工作。我在这里错过了什么吗?

    // Create the web client and enable SSL/TLS with a trust store
    WebClient client = WebClient.create(vertx,
            new WebClientOptions()
                    .setSsl(false)
                    .setTrustAll(true)
                    .setDefaultPort(80)
                    .setKeepAlive(true)
                    .setDefaultHost("www.nasdaq.com"));


    client.get(80, "www.nasdaq.com", "/screening/companies-by-industry.aspx")
            .addQueryParam("exchange", "NASDAQ")
            .addQueryParam("render", "download")
            .putHeader("content-type","text/csv")
            .as(BodyCodec.string())
            .send(ar -> {
                if (ar.succeeded()) {

                    // HttpResponse<Void> response = ar.result();

                    System.out.println("Received response with status code");
                } else {
                    System.out.println("Something went wrong " + ar.cause().getMessage());
                }
            });
4

1 回答 1

1

既然我想通了,就在这里回答这个问题。

问题是网站重定向到不同的下载 url,但 VertxWebClient未来没有完成。它至少应该返回一个状态码 302 来说明原因 - 叹息!

于 2018-09-17T18:19:25.600 回答