驗證碼識別破解
阿新 • • 發佈:2018-11-29
針對比較整齊的數字驗證碼
過程:提取資料模型,根據資料模型匹配圖片驗證碼
圖示:
詳細步驟:
一 提取資料模型:
從網路地址獲取圖片
public static void getImage()
{
try {
URL url = new URL("http://10.7.84.10:7001/exchange/imgcode?Fri%20Jun%2024%202016%2010:02:26%20GMT+0800%20(%E4%B8%AD%E5%9B%BD%E6%A0%87%E5%87%86%E6%97%B6%E9%97 %B4)?Fri%20Jun%2024%202016%2010:02:26%20GMT+0800%20(%E4%B8%AD%E5%9B%BD%E6%A0%87%E5%87%86%E6%97%B6%E9%97%B4)?Fri%20Jun%2024%202016%2010:02:52%20GMT+0800%20(%E4%B8%AD%E5%9B%BD%E6%A0%87%E5%87%86%E6%97%B6%E9%97%B4)"); //返回的是4位驗證碼的圖片
File outFile = new File("C:\\a.jpg");
OutputStream os = new FileOutputStream(outFile);
BufferedReader bf = new BufferedReader(new InputStreamReader(url.openStream()));
InputStream is = (InputStream) url.openStream();
byte[] buff = new byte[1024 ];
while(true) { //要注意這種寫法
int readed = is.read(buff);
if(readed == -1) {
break;
}
byte[] temp = new byte[readed];
System.arraycopy(buff, 0, temp, 0, readed); // 這句是關鍵
os.write (temp);
}
is.close();
os.close();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
- 將圖片黑化,裁剪,等值分割,獲取拆分後的每個數字的圖片
————————–未完