尝试使用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());
}
});
答案 0 :(得分:1)
自从我弄清楚了,在这里回答这个问题。
问题是网站重定向到另一个下载URL,但Vertx WebClient
的未来还没有完成。它至少应该返回状态码302来说明原因-叹气!