精华帖 (1) :: 良好帖 (1) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2012-04-10
tangzililiang 写道 别把用户名和密码一起收集了,代码还要重构,一个字:乱~ 把用户名和密码一起顺便收集了,人人就真他草泥个国内领先实名制了。 --狂草人人大业 |
|
返回顶楼 | |
发表时间:2012-04-10
代码命名好。。。乱
|
|
返回顶楼 | |
发表时间:2012-04-11
最后修改:2012-04-11
建议大家不要偷菜,因为偷菜如果遇到有狗的、有蜜蜂的将会失掉非常多的金币,本人以前的程序就有此功能,后来给删除了,
|
|
返回顶楼 | |
发表时间:2012-04-11
上传文件 上传文件 上传文件
|
|
返回顶楼 | |
发表时间:2012-04-11
LZ是如何将验证码显示在程序上的
用HttpClient模拟浏览器操作,遇到验证我无奈啊,就是搞不出来,痛苦万分。 |
|
返回顶楼 | |
发表时间:2012-04-11
参见loginButtonActionPerformed,如果第一次login失败,在返回的String中会含有验证图形的标记,得到图形后显示给客户要求重新输入并再次login。
private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) { // update user info. currentUser.setUsername(usernameTextField.getText()); currentUser.setPassword(passwordTextField.getText()); // clear output outputTextArea.setText("---- " + (new Date()).toString() + " ----\n"); verifyCode = verifyTextField.getText(); //outputTextArea.append("Verify code = '" + verifyCode + "'"); System.out.println("Verify code = '" + verifyCode + "'"); boolean firstTimeLogon; if (!verifyCodeFlag) { // first time, no verify image firstTimeLogon = renren.logon(currentUser); } else { // firstTimeLogon = renren.logon(currentUser, verifyCode); } //System.out.println("first time logon : " + firstTimeLogon); if (firstTimeLogon) { // login success thread.start(); } if (!firstTimeLogon) { // require verify code System.out.println("verify image url : " + renren.getVerifyImageUrl()); // show verify image try { bais = renren.getRenrenVerifyImage(); System.out.println("bais.size() = " + bais.size()); String digest = getDigest_md5(bais); System.out.println("Digest_md5 = '" + digest + "'"); Image image = ImageIO.read(new ByteArrayInputStream(bais.toByteArray())); imgPanel.removeAll(); JLabel label = new JLabel(new ImageIcon(image)); imgPanel.add(label); verifyCodeFlag = true; // redraw layout verifyTextField.setText(""); gifPanel.setVisible(true); validate(); repaint(); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } } } |
|
返回顶楼 | |
发表时间:2012-04-12
yang02301 写道 参见loginButtonActionPerformed,如果第一次login失败,在返回的String中会含有验证图形的标记,得到图形后显示给客户要求重新输入并再次login。
private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) { // update user info. currentUser.setUsername(usernameTextField.getText()); currentUser.setPassword(passwordTextField.getText()); // clear output outputTextArea.setText("---- " + (new Date()).toString() + " ----\n"); verifyCode = verifyTextField.getText(); //outputTextArea.append("Verify code = '" + verifyCode + "'"); System.out.println("Verify code = '" + verifyCode + "'"); boolean firstTimeLogon; if (!verifyCodeFlag) { // first time, no verify image firstTimeLogon = renren.logon(currentUser); } else { // firstTimeLogon = renren.logon(currentUser, verifyCode); } //System.out.println("first time logon : " + firstTimeLogon); if (firstTimeLogon) { // login success thread.start(); } if (!firstTimeLogon) { // require verify code System.out.println("verify image url : " + renren.getVerifyImageUrl()); // show verify image try { bais = renren.getRenrenVerifyImage(); System.out.println("bais.size() = " + bais.size()); String digest = getDigest_md5(bais); System.out.println("Digest_md5 = '" + digest + "'"); Image image = ImageIO.read(new ByteArrayInputStream(bais.toByteArray())); imgPanel.removeAll(); JLabel label = new JLabel(new ImageIcon(image)); imgPanel.add(label); verifyCodeFlag = true; // redraw layout verifyTextField.setText(""); gifPanel.setVisible(true); validate(); repaint(); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } } } 奇怪了,这个验证码怎么会是image.jpg而有的验证码是没有的,比如这个验证码,你看下 http://www.zjgsdx.com/bbs/logging.php?action=login |
|
返回顶楼 | |
发表时间:2012-04-15
endual 写道 yang02301 写道 参见loginButtonActionPerformed,如果第一次login失败,在返回的String中会含有验证图形的标记,得到图形后显示给客户要求重新输入并再次login。
private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) { // update user info. currentUser.setUsername(usernameTextField.getText()); currentUser.setPassword(passwordTextField.getText()); // clear output outputTextArea.setText("---- " + (new Date()).toString() + " ----\n"); verifyCode = verifyTextField.getText(); //outputTextArea.append("Verify code = '" + verifyCode + "'"); System.out.println("Verify code = '" + verifyCode + "'"); boolean firstTimeLogon; if (!verifyCodeFlag) { // first time, no verify image firstTimeLogon = renren.logon(currentUser); } else { // firstTimeLogon = renren.logon(currentUser, verifyCode); } //System.out.println("first time logon : " + firstTimeLogon); if (firstTimeLogon) { // login success thread.start(); } if (!firstTimeLogon) { // require verify code System.out.println("verify image url : " + renren.getVerifyImageUrl()); // show verify image try { bais = renren.getRenrenVerifyImage(); System.out.println("bais.size() = " + bais.size()); String digest = getDigest_md5(bais); System.out.println("Digest_md5 = '" + digest + "'"); Image image = ImageIO.read(new ByteArrayInputStream(bais.toByteArray())); imgPanel.removeAll(); JLabel label = new JLabel(new ImageIcon(image)); imgPanel.add(label); verifyCodeFlag = true; // redraw layout verifyTextField.setText(""); gifPanel.setVisible(true); validate(); repaint(); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } } } 奇怪了,这个验证码怎么会是image.jpg而有的验证码是没有的,比如这个验证码,你看下 http://www.zjgsdx.com/bbs/logging.php?action=login 看了一下http://www.zjgsdx.com/bbs/logging.php?action=login,编程方法类似: httpget = new HttpGet("http://www.zjgsdx.com/bbs/seccode.php?update=82986); httpget.setHeader("Accept", "*/*"); httpget.setHeader("Accept-Encoding", "gzip, deflate"); httpget.setHeader("Accept-Language", "en-US"); httpget.setHeader("Connection", "Keep-Alive"); httpget.setHeader("Cookie", cookieString); httpget.setHeader("Host", "www.zjgsdx.com"); httpget.setHeader("Referer", "http://www.zjgsdx.com/bbs/logging.php?action=login&referer=http%3A//www.zjgsdx.com/bbs/memcp.php"); httpget.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)"); response = httpclient.execute(httpget); System.out.println("get verify picture : response.getStatusLine().getStatusCode() = " + response.getStatusLine().getStatusCode()); System.out.println("Content-Type:" + response.getHeaders("Content-Type")[0].getValue()); entity = response.getEntity(); InputStream inputStream = new GzipDecompressingEntity(entity).getContent(); // write the inputStream to a FileOutputStream OutputStream out = new FileOutputStream(new File("c:\\newfile.png")); int read = 0; byte[] bytes = new byte[1024]; while ((read = inputStream.read(bytes)) != -1) { out.write(bytes, 0, read); } inputStream.close(); out.flush(); out.close(); System.out.println("Check file c:\\newfile.png"); |
|
返回顶楼 | |