public static String kuari_post_get_qr(String url, String code ) throws ClientProtocolException, IOException { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httppost = new HttpPost(url); httppost.setHeader("Accept", "*/*"); httppost.setHeader("Accept-Encoding", "gzip, deflate"); httppost.setHeader("Accept-Language", "zh-CN,zh;q=0.9"); httppost.setHeader("Connection", "keep-alive"); httppost.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); httppost.setHeader("User-Agent", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.6045.160 Mobile Safari/537.36"); // 创建参数队列 List<NameValuePair> formparams = new ArrayList<NameValuePair>(); String result = null; formparams.add(new BasicNameValuePair("code", code)); UrlEncodedFormEntity uefEntity; uefEntity = new UrlEncodedFormEntity(formparams, "UTF-8"); httppost.setEntity(uefEntity); // System.out.println("executing request " + httppost.getURI()); CloseableHttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); if (entity != null) { result = EntityUtils.toString(entity, "UTF-8"); } response.close(); httpclient.close(); return result; } String code8 = kuari_post_get_qr("
抓包抓到的内容是:
为什么要这个软件,因为哪个网站防止f12 会跳转别的页面,试过别的方法不行。 所以只能这个软件了。
模仿的代码是
public static String kuari_post_get_qr2(String webSite, String api, String code) { try { // 发送预检请求(OPTIONS 请求) URL optionsUrl = new URL(webSite + api); HttpURLConnection optionsConn = (HttpURLConnection) optionsUrl.openConnection(); optionsConn.setRequestMethod("OPTIONS"); int optionsResponseCode = optionsConn.getResponseCode(); System.out.println("OPTIONS Response Code: " + optionsResponseCode); // 发送实际的 POST 请求 URL postUrl = new URL(webSite + api); HttpURLConnection postConn = (HttpURLConnection) postUrl.openConnection(); postConn.setRequestMethod("POST"); postConn.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); JSONObject object = new JSONObject(); object.put("code", code); String jsonInputString = object.toString(); //String jsonInputString = "{\"account\": \"BC-Kh7whgUzNFv5p77QwQh9U\"}"; postConn.setDoOutput(true); DataOutputStream postOut = new DataOutputStream(postConn.getOutputStream()); postOut.write(jsonInputString.getBytes("UTF-8")); postOut.flush(); postOut.close(); int postResponseCode = postConn.getResponseCode(); System.out.println("POST Response Code: " + postResponseCode); BufferedReader postIn = new BufferedReader(new InputStreamReader(postConn.getInputStream())); String postInputLine; StringBuffer postResponse = new StringBuffer(); while ((postInputLine = postIn.readLine()) != null) { postResponse.append(postInputLine); } postIn.close(); System.out.println("POST Response: " + postResponse.toString()); return postResponse.toString(); } catch (Exception e) { e.printStackTrace(); } return null; }
{"error":"","responseData":{"images":"http://kuaristatic.space/upload/def_code.jpg" ,"url":"http://r6960.cn?intothis=8p/wHmwRvpJE1DwJW+zzGqLWSiJ5hr1WLGZEv5pQ92w="},"status":200}
站长微信:xiaomao0055
站长QQ:14496453