1、快速使用
CloseableHttpClient client = HttpClients.custom()
.setDefaultCookieStore(new BasicCookieStore()).build();
String uuid = UUID.randomUUID().toString().toUpperCase();
String url = "https://passport.baidu.com/v2/api/qrcode?sign=" + uuid + "&lp=pc&qrloginfrom=pc";
HttpGet get = new HttpGet(url);
HttpResponse res = client.execute(get);
HttpEntity entity = res.getEntity();
InputStream is = entity.getContent();
FileOutputStream out = new FileOutputStream(new File("C:\\Users\\xiaoyu\\Desktop\\qr.png"));
int len = 0;
while((len = is.read()) != -1) {
out.write(len);
}
out.close();
is.close();