imageCrawler.jsp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  4. <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
  5. <%
  6. String path = request.getContextPath();
  7. String basePath = request.getScheme() + "://"
  8. + request.getServerName() + ":" + request.getServerPort()
  9. + path + "/";
  10. %>
  11. <!DOCTYPE html>
  12. <html lang="en">
  13. <head>
  14. <base href="<%=basePath%>">
  15. <!-- jsp文件头和头部 -->
  16. <!-- page specific plugin styles -->
  17. <link rel="stylesheet" href="static/ace/css/colorbox.css" />
  18. <%@ include file="../../system/index/top.jsp"%>
  19. </head>
  20. <body class="no-skin">
  21. <!-- /section:basics/navbar.layout -->
  22. <div class="main-container" id="main-container">
  23. <!-- /section:basics/sidebar -->
  24. <div class="main-content">
  25. <div class="main-content-inner">
  26. <div class="page-content">
  27. <div class="hr hr-18 dotted hr-double"></div>
  28. <div class="row">
  29. <div class="col-xs-12">
  30. <div class="well well-sm">
  31. <h4 class="lighter no-margin-bottom">
  32. <i class="ace-icon fa fa-hand-o-right icon-animated-hand-pointer blue"></i>
  33. <span class="input-icon">
  34. <input type="text" id="serverUrl" title="请输入要爬的网页地址" placeholder="请输入要爬的网页地址" style="width:540px;">
  35. <i class="ace-icon fa fa-globe"></i>
  36. </span>
  37. <a class="btn btn-xs btn-info" title='爬取' onclick="getUrl('');">
  38. <i class="ace-icon fa fa-cloud-download bigger-120" title="爬取"></i>
  39. </a>
  40. &nbsp;
  41. <a class="btn btn-xs btn-info" title='请求' onclick="getUrl('save');" id="savebut">
  42. 保存至服务器
  43. </a>
  44. </h4>
  45. </div>
  46. <div class="hr hr-16 hr-dotted"></div>
  47. <div>
  48. <ul class="ace-thumbnails clearfix" id="imgList">
  49. <!-- #section:pages/gallery -->
  50. <li style="display: none;">
  51. <a href="" data-rel="colorbox">
  52. <img width="150" height="150" alt="150x150" src="" />
  53. </a>
  54. </li>
  55. </ul>
  56. </div><!-- PAGE CONTENT ENDS -->
  57. <div class="hr hr-18 dotted hr-double"></div>
  58. </div>
  59. <!-- /.col -->
  60. </div>
  61. <!-- /.row -->
  62. </div>
  63. <!-- /.page-content -->
  64. </div>
  65. </div>
  66. <!-- /.main-content -->
  67. <!-- 返回顶部 -->
  68. <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
  69. <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
  70. </a>
  71. </div>
  72. <!-- /.main-container -->
  73. <!-- basic scripts -->
  74. <!-- 页面底部js¨ -->
  75. <%@ include file="../../system/index/foot.jsp"%>
  76. <script src="static/ace/js/jquery.colorbox.js"></script>
  77. <!-- ace scripts -->
  78. <script src="static/ace/js/ace/ace.js"></script>
  79. <!--提示框-->
  80. <script type="text/javascript" src="static/js/jquery.tips.js"></script>
  81. <script type="text/javascript">
  82. $(getTop(globalThis).hangge());
  83. //图片效果
  84. jQuery(function($) {
  85. var $overflow = '';
  86. var colorbox_params = {
  87. rel: 'colorbox',
  88. reposition:true,
  89. scalePhotos:true,
  90. scrolling:false,
  91. previous:'<i class="ace-icon fa fa-arrow-left"></i>',
  92. next:'<i class="ace-icon fa fa-arrow-right"></i>',
  93. close:'&times;',
  94. current:'{current} of {total}',
  95. maxWidth:'100%',
  96. maxHeight:'100%',
  97. onOpen:function(){
  98. $overflow = document.body.style.overflow;
  99. document.body.style.overflow = 'hidden';
  100. },
  101. onClosed:function(){
  102. document.body.style.overflow = $overflow;
  103. },
  104. onComplete:function(){
  105. $.colorbox.resize();
  106. }
  107. };
  108. $('.ace-thumbnails [data-rel="colorbox"]').colorbox(colorbox_params);
  109. $("#cboxLoadingGraphic").html("<i class='ace-icon fa fa-spinner orange fa-spin'></i>");//let's add a custom loading icon
  110. });
  111. //请求连接地址发送给后台处理
  112. function getUrl(msg){
  113. var serverUrl = $("#serverUrl").val();
  114. if("" == serverUrl){
  115. $("#serverUrl").tips({
  116. side:3,
  117. msg:'请输入要爬取的地址',
  118. bg:'#FF5080',
  119. time:3
  120. });
  121. return;
  122. }
  123. if("save" == msg){
  124. $("#savebut").tips({
  125. side:3,
  126. msg:'提交成功,等待保存完毕',
  127. bg:'#4682B4',
  128. time:5
  129. });
  130. }
  131. getTop(globalThis).jzts();
  132. $.ajax({
  133. type: "POST",
  134. url: '<%=basePath%>pictures/getImagePath.do',
  135. data: {serverUrl:serverUrl,msg:msg,tm:new Date().getTime()},
  136. dataType:'json',
  137. cache: false,
  138. success: function(data){
  139. if("success" == data.result){
  140. $("#imgList").html('');
  141. var count = 0; //总数
  142. $.each(data.imgList, function(i, imgPath){
  143. $("#imgList").append(
  144. '<li>'+
  145. '<a href="'+imgPath+'" data-rel="colorbox" class="cboxElement">'+
  146. '<img width="150" height="150" alt="150x150" src="'+imgPath+'" />'+
  147. '<div class="text">'+
  148. '<div class="inner">FH</div>'+
  149. '</div>'+
  150. '</a>'+
  151. '</li>'
  152. );
  153. count = i+1;
  154. });
  155. $("#serverUrl").tips({
  156. side:3,
  157. msg:'成功爬到 '+count+' 张图片',
  158. bg:'#4682B4',
  159. time:9999
  160. });
  161. }else if("error" == data.result){
  162. $("#serverUrl").tips({
  163. side:3,
  164. msg:'爬取失败,地址错误或没有图片',
  165. bg:'#FF5080',
  166. time:10
  167. });
  168. }else if("saveok" == data.result){
  169. $("#serverUrl").tips({
  170. side:3,
  171. msg:'保存成功至图片列表',
  172. bg:'#00A600',
  173. time:9999
  174. });
  175. }
  176. $(getTop(globalThis).hangge());
  177. }
  178. });
  179. }
  180. </script>
  181. </body>
  182. </html>