12306最后一步验证码自动识别出来了提交显示请不要重复提交订单问题。急!急!急!急!急!急!

hncdyj 2012-11-05 12:30:58
本人出于好奇,准备写个抢票软件。现在界面已经画好了,登录逻辑都是可以登录上的。因为最后一步提交订单遇到问题。(铁道部服务器返回{"msgError":"请不要重复提交!"},大概就是这意思,我是用httpwatch抓的请求,firebug有些请求抓不到)所以还没有着手写界面上的订票逻辑,还没有用到线程自动监控。
登录运气好一次识别,运气不好基本也不会超过十次。

在之前请安装验证码识别引擎库。
tesseract-ocr-setup-3.00.exe(已传到google code上)
请大侠帮助小弟实现最后一步。本人不生感激。这是造福苍生的事。
相关代码已经上传到了google code上面。
https://mygod-go-home.googlecode.com/svn/trunk/
装好验证码识别引擎后,修改一下OCR.java中的tessPath,把tessPath指向验证码识别引擎的安装路径。
相关测试的业务逻辑在test包下的main.java。运行测试方法前先用界面登录拿到2个cookie值,赋值到main.java的两个常量里面。
...全文
11145 53 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
53 条回复
切换为时间正序
请发表友善的回复…
发表回复
fy_back 2014-09-19
  • 打赏
  • 举报
回复
各位大神有最新的java源码吗?有的话请赐教,我邮箱1051834224@qq.com
qin1028 2014-03-11
  • 打赏
  • 举报
回复
我想知道验证码自动识别是怎么做到的,跪求分享1178171582@qq.com
  • 打赏
  • 举报
回复
submitOrderRequest的时候老是这种错误。。。。 请问一下如何解决? 谢谢 {"validateMessagesShowId":"_validatorMessage","url":"/leftTicket/init","status":false,"httpstatus":200,"messages":["系统忙,请稍后重试"],"validateMessages":{}}
jlu 2013-12-25
  • 打赏
  • 举报
回复
拜求一份源码,十二分感激,jlusz@hotmail.com。
jayjiea 2013-12-11
  • 打赏
  • 举报
回复
今年的泡汤了
yyoosn 2013-07-15
  • 打赏
  • 举报
回复
楼主求一份源码,不胜感激,主要是你这个界面我逻辑我想参考下 我这里有破解验证码的code 识别率大概在40%左右,够用,希望相互参考,相互进步 发到我邮箱 1526192844@qq.com
huoyunxieren 2013-06-13
  • 打赏
  • 举报
回复
这个软件很好,求一份源代码。840378023@qq.com.还望大家支持,相互学习,共同进步,在这里先谢谢了!
卑微程序员 2013-03-26
  • 打赏
  • 举报
回复
厉害
lxr0530 2013-03-07
  • 打赏
  • 举报
回复
继续顶起,永不沉落,支持楼主,要是能早日解决验证码问题,可以解救我们贫苦大众了
网络科技 2013-02-02
  • 打赏
  • 举报
回复
不错,先马克下。
皮球·爸爸 2013-01-24
  • 打赏
  • 举报
回复
/**
 * 测试验证码解析
 * @author hanmanyi
 *
 */
public class TestOCR {
	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		String path = "E:\\ZGCCZJworksp\\HMYTicket\\image\\passCode.jpg";
//		String path = "E:\\ZGCCZJworksp\\HMYTicket\\image\\untitled.bmp";
		
//		for (int i = 0; i < 100; i++) {
			try {
				
				filter(path);
//				String valCode = new OCR().recognizeText("C:\\Program Files\\Tesseract-OCR\\",new File(path), "jpg");
//				String valCode = new OCR().recognizeText("C:\\Program Files\\Tesseract-OCR\\",new File(path), "bmp");
//				valCode = valCode.replace("\r\n\r\n", "");
//				System.out.println(i+"|"+valCode);
//			} catch (IOException e) {
//				e.printStackTrace();
			} 
			catch (Exception e) {
				e.printStackTrace();
			}
//		}
	}
	/**
	 * 过滤掉图片中的直线和孤立点
	 * 用被使用最多的颜色(即背景色)代替
	 * 
	 */
	public static void filter(String path) {
		InputStream instream;
		OutputStream out;
		String newpath = "E:\\ZGCCZJworksp\\HMYTicket\\image\\new_passCode.jpg";
		try {
			BufferedImage imgOrg = ImageIO.read(new File(path));
			
			instream = convert(imgOrg);
//			instream = new FileInputStream(new File(path));
			out = new FileOutputStream(new File(newpath));
			int byteread = 0;
			byte[] tmp = new byte[1];
			while ((byteread = instream.read(tmp)) != -1) {
				out.write(tmp);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 用被使用最多的颜色(即背景色)代替
	 * @param imgOrg
	 */
	private static InputStream convert(BufferedImage img) {
		InputStream is = null;
		int width = img.getWidth();
		int height = img.getHeight();
		for (int j = 0; j < height; j++) {
			for (int i = 0; i < width; i++) {
				Long RGB = Long.parseLong(""+img.getRGB(i, j));
				Map<Long, Integer> map = getMaxColor(img,i,j);
				Integer c = map.get(RGB);
				
				System.out.println(RGB);
				System.out.println(map);
				if (c != null && c >1) {
					img.setRGB(i, j, 0xFF0000);
				}
			}
		}
		img.flush();
		ImageOutputStream imOut;
		ByteArrayOutputStream bs = new ByteArrayOutputStream();
		try {
			imOut = ImageIO.createImageOutputStream(bs);
			ImageIO.write(img, "jpg",imOut);
			is= new ByteArrayInputStream(bs.toByteArray());
			} catch (IOException e) {
				e.printStackTrace();
			}
			
			
			
		return is;
	}
	
	/**
	 * 周围使用最多的颜色
	 * @param imgOrg
	 */
	private static Map<Long, Integer> getMaxColor(BufferedImage img,int x,int y){
		int width = img.getWidth();
		int height = img.getHeight();
		int range = 2;
		
		Map<Long, Integer> map = new HashMap<Long, Integer>();
		for (int j = y-range < 0?0:y-range; j < height && j<=y+range ; j++) {
			for (int i = x-range < 0?0:x-range; i < width && i<=x+range; i++) {
				long RGB = img.getRGB(i, j);
				Integer c = map.get(RGB);
				if (c == null) {
					map.put(RGB, 1);
				} else {
					map.put(RGB, c + 1);
				}
			}
		}
		return map;
	}
}
皮球·爸爸 2013-01-24
  • 打赏
  • 举报
回复
去干扰点 还有戏,去干扰线 有些恶心啊。、、 一条线段上某一点周围的8个点中 居然 没有两个相同的RGB值。。我就擦了。。
joe590 2013-01-22
  • 打赏
  • 举报
回复
主要想了解自动识别验证码。
青苔猿猿 2013-01-18
  • 打赏
  • 举报
回复
我已经在12306上定了6天啦,也没有顶上票!!!!!!
pby_bob 2013-01-15
  • 打赏
  • 举报
回复
支持下,楼主继续修改bug
LongRain_CQ 2013-01-12
  • 打赏
  • 举报
回复
其实我想知道楼主是怎么样可以自动识别难证码的.
蛋蛋の忧伤 2013-01-12
  • 打赏
  • 举报
回复
不错呢 难道铁道部出接口了?
点康 2013-01-10
  • 打赏
  • 举报
回复
如有.NET的麻烦分享一个吧
alexmayer 2013-01-10
  • 打赏
  • 举报
回复
顶一下! 支持!
NTHeiXia 2012-12-21
  • 打赏
  • 举报
回复
楼主可以有空我们可以多多交流:我的qq:171531134
加载更多回复(32)

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧