找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 6568|回复: 3

年前最后一篇压轴:自己动手写全网最强网盘搜索引擎

[复制链接]

307

主题

228

回帖

7343

积分

用户组: 真·技术宅

UID
2
精华
76
威望
291 点
宅币
5593 个
贡献
253 次
宅之契约
0 份
在线时间
948 小时
注册时间
2014-1-25
发表于 2014-1-29 12:53:26 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
PS:是否因为搜不到文件而苦恼?是否因为完不成老板交代的非人类任务而感到迷茫?是否因为不是程序猿而感觉悲伤想重新投胎?不用怕,这篇文章解决你的所有困扰。写这个是看到了网上传的网盘搜索引擎功能不错,为了知道怎么实现的,我进行了逆向,发现了他们的秘密,其实就是用搜索引擎的高级搜索方式,使用关键字,类似site:(pan.baidu.com) title:(动力火车),把这个搜索语句发给百度或者谷歌进行搜索。了解了原理之后便做了个java界面版的更强大的工具,你不要感到我在吹牛,因为我已经做出来了。很多网站也有搜索功能,不过方式都是类似于这个啦,而且他们支持的都不多不全面而且不能让你调整搜索设置。我的习惯是公布源代码,注释比较少啊。我试过google发现在相同情况下对中文资源搜索完全没有百度多,因此打消了原想做2套引擎的想法。高级搜索配置我也做了不过最后被我删了,不实用,不适合普通大众。这次支持的网盘如下(记得都是可以自己改的):
1.png
下面是仅在各大网盘资源标题中搜索directx pdf的结果,还是很丰盛的
2.png
这个页面可以动态调整大小的,用起来还是很爽的,说实话java这2个代码写的ui部分比其他部分多。。。要知道2天内写1000行java代码,我太崇拜自己了,创造出这么个神器。呵呵
下面是代码:
  1. import java.awt.Color;import java.awt.event.MouseAdapter;
  2. import java.awt.event.MouseEvent;
  3. import java.awt.event.MouseListener;
  4. import javax.swing.ButtonGroup;
  5. import javax.swing.JButton;
  6. import javax.swing.JCheckBox;
  7. import javax.swing.JFrame;
  8. import javax.swing.JLabel;
  9. import javax.swing.JRadioButton;
  10. import javax.swing.JSeparator;
  11. import javax.swing.SwingConstants;
  12. import javax.swing.JTextField;
  13. public class DevineSearch extends JFrame implements MouseListener
  14. {
  15.         /**
  16.           *
  17.           */
  18.         private static final long serialVersionUID = 1L;
  19.         private final ButtonGroup searchallconfig = new ButtonGroup();
  20.         private JCheckBox[] wangpanarray=null;
  21.         private JCheckBox[] websitearray=null;
  22.         private JCheckBox[] otherarray=null;
  23.         private JCheckBox allthings=null;
  24.         private JCheckBox wangpan=null;
  25.         private JCheckBox wangzhanluntan=null;
  26.         private JCheckBox others=null;
  27.         public static ResultList result=null;
  28.         public static boolean StopSearch=false;
  29.         private JTextField ToSearch;
  30.         private static final int selallhtmsandfiles=0;
  31.         private static final int selpdfs=1;
  32.         private static final int seldocs=2;
  33.         private static final int selxlss=3;
  34.         private static final int selppts=4;
  35.         private static final int selrtfs=5;
  36.         private static final int selallformats=6;
  37.         private static final int seaanywhere=7;
  38.         private static final int seatitle=8;
  39.         private static final int seaurl=9;
  40.         private static int selformat=selallhtmsandfiles;
  41.         private static int seaplace=seatitle;
  42.         private final ButtonGroup searchplace = new ButtonGroup();

  43.         public DevineSearch()
  44.         {
  45.                 super("lichao890427的搜索引擎");
  46.                 setTitle("lichao890427的搜索引擎");
  47.                 getContentPane().setLayout(null);
  48.                
  49.                 JCheckBox baidu = new JCheckBox("\u767E\u5EA6\u7F51\u76D8");
  50.                 baidu.setForeground(Color.BLACK);
  51.                 baidu.setSelected(true);
  52.                 baidu.setBounds(138, 43, 100, 23);
  53.                 getContentPane().add(baidu);
  54.                
  55.                 JCheckBox _115wangpan = new JCheckBox("115\u7F51\u76D8");
  56.                 _115wangpan.setSelected(true);
  57.                 _115wangpan.setBounds(240, 43, 100, 23);
  58.                 getContentPane().add(_115wangpan);
  59.                
  60.                 JCheckBox huawei1 = new JCheckBox("\u534E\u4E3A\u7F51\u76D81");
  61.                 huawei1.setSelected(true);
  62.                 huawei1.setBounds(342, 43, 100, 23);
  63.                 getContentPane().add(huawei1);
  64.                
  65.                 JCheckBox huawei2 = new JCheckBox("\u534E\u4E3A\u7F51\u76D82");
  66.                 huawei2.setSelected(true);
  67.                 huawei2.setBounds(444, 43, 100, 23);
  68.                 getContentPane().add(huawei2);
  69.                
  70.                 JCheckBox jinshankuaipan = new JCheckBox("\u91D1\u5C71\u5FEB\u76D8");
  71.                 jinshankuaipan.setSelected(true);
  72.                 jinshankuaipan.setBounds(546, 43, 100, 23);
  73.                 getContentPane().add(jinshankuaipan);
  74.                
  75.                 JCheckBox lianxiang = new JCheckBox("\u8054\u60F3\u7F51\u76D8");
  76.                 lianxiang.setSelected(true);
  77.                 lianxiang.setBounds(648, 43, 100, 23);
  78.                 getContentPane().add(lianxiang);
  79.                
  80.                 JCheckBox yimuhe = new JCheckBox("\u4E00\u6728\u79BE\u7F51\u76D8");
  81.                 yimuhe.setSelected(true);
  82.                 yimuhe.setBounds(138, 68, 100, 23);
  83.                 getContentPane().add(yimuhe);
  84.                
  85.                 JSeparator separator = new JSeparator();
  86.                 separator.setBackground(Color.BLUE);
  87.                 separator.setOrientation(SwingConstants.VERTICAL);
  88.                 separator.setForeground(Color.BLUE);
  89.                 separator.setBounds(130, 0, 2, 400);
  90.                 getContentPane().add(separator);
  91.                
  92.                 allthings = new JCheckBox("\u7F51\u9875\u548C\u6587\u4EF6");
  93.                 allthings.setBounds(6, 6, 118, 23);
  94.                 getContentPane().add(allthings);
  95.                
  96.                 wangpan = new JCheckBox("\u7F51\u76D8\u8D44\u6E90");
  97.                 wangpan.setSelected(true);
  98.                 wangpan.setBounds(6, 43, 118, 23);
  99.                 getContentPane().add(wangpan);
  100.                
  101.                 wangzhanluntan = new JCheckBox("\u7F51\u7AD9\u8BBA\u575B\u8D44\u6E90");
  102.                 wangzhanluntan.setBounds(6, 153, 118, 23);
  103.                 getContentPane().add(wangzhanluntan);
  104.                
  105.                 JSeparator separator_1 = new JSeparator();
  106.                 separator_1.setForeground(Color.BLUE);
  107.                 separator_1.setBackground(Color.BLUE);
  108.                 separator_1.setBounds(0, 35, 764, 2);
  109.                 getContentPane().add(separator_1);
  110.                
  111.                 JCheckBox namipan = new JCheckBox("\u7EB3\u7C73\u76D8");
  112.                 namipan.setSelected(true);
  113.                 namipan.setBounds(240, 68, 100, 23);
  114.                 getContentPane().add(namipan);
  115.                
  116.                 JCheckBox qianjunwanma = new JCheckBox("\u5343\u519B\u4E07\u9A6C\u7F51\u76D8");
  117.                 qianjunwanma.setSelected(true);
  118.                 qianjunwanma.setBounds(342, 68, 100, 23);
  119.                 getContentPane().add(qianjunwanma);
  120.                
  121.                 JCheckBox keleyun = new JCheckBox("\u53EF\u4E50\u4E91\u7F51\u76D8");
  122.                 keleyun.setSelected(true);
  123.                 keleyun.setBounds(444, 68, 100, 23);
  124.                 getContentPane().add(keleyun);
  125.                
  126.                 JSeparator separator_2 = new JSeparator();
  127.                 separator_2.setForeground(Color.BLUE);
  128.                 separator_2.setBackground(Color.BLUE);
  129.                 separator_2.setBounds(0, 145, 764, 2);
  130.                 getContentPane().add(separator_2);
  131.                
  132.                 JRadioButton allhtmsandfiles = new JRadioButton("\u6240\u6709\u7F51\u9875\u548C\u6587\u4EF6");
  133.                 allhtmsandfiles.addMouseListener(new MouseAdapter()
  134.                 {
  135.                         @Override
  136.                         public void mouseClicked(MouseEvent arg0)
  137.                         {
  138.                                 selformat=selallhtmsandfiles;
  139.                         }
  140.                 });
  141.                 allhtmsandfiles.setSelected(true);
  142.                 searchallconfig.add(allhtmsandfiles);
  143.                 allhtmsandfiles.setBounds(138, 6, 120, 23);
  144.                 getContentPane().add(allhtmsandfiles);
  145.                
  146.                 JRadioButton pdfs = new JRadioButton("pdf");
  147.                 pdfs.addMouseListener(new MouseAdapter()
  148.                 {
  149.                         @Override
  150.                         public void mouseClicked(MouseEvent arg0)
  151.                         {
  152.                                 selformat=selpdfs;
  153.                         }
  154.                 });
  155.                 searchallconfig.add(pdfs);
  156.                 pdfs.setBounds(260, 6, 60, 23);
  157.                 getContentPane().add(pdfs);
  158.                
  159.                 JRadioButton docs = new JRadioButton("doc");
  160.                 docs.addMouseListener(new MouseAdapter()
  161.                 {
  162.                         @Override
  163.                         public void mouseClicked(MouseEvent arg0)
  164.                         {
  165.                                 selformat=seldocs;
  166.                         }
  167.                 });
  168.                 searchallconfig.add(docs);
  169.                 docs.setBounds(322, 6, 60, 23);
  170.                 getContentPane().add(docs);
  171.                
  172.                 JRadioButton xlss = new JRadioButton("xls");
  173.                 xlss.addMouseListener(new MouseAdapter()
  174.                 {
  175.                         @Override
  176.                         public void mouseClicked(MouseEvent arg0)
  177.                         {
  178.                                 selformat=selxlss;
  179.                         }
  180.                 });
  181.                 searchallconfig.add(xlss);
  182.                 xlss.setBounds(384, 6, 60, 23);
  183.                 getContentPane().add(xlss);
  184.                
  185.                 JRadioButton ppts = new JRadioButton("ppt");
  186.                 ppts.addMouseListener(new MouseAdapter()
  187.                 {
  188.                         @Override
  189.                         public void mouseClicked(MouseEvent arg0)
  190.                         {
  191.                                 selformat=selppts;
  192.                         }
  193.                 });
  194.                 searchallconfig.add(ppts);
  195.                 ppts.setBounds(446, 6, 60, 23);
  196.                 getContentPane().add(ppts);
  197.                
  198.                 JRadioButton rtfs = new JRadioButton("rtf");
  199.                 rtfs.addMouseListener(new MouseAdapter()
  200.                 {
  201.                         @Override
  202.                         public void mouseClicked(MouseEvent arg0)
  203.                         {
  204.                                 selformat=selrtfs;
  205.                         }
  206.                 });
  207.                 searchallconfig.add(rtfs);
  208.                 rtfs.setBounds(506, 6, 60, 23);
  209.                 getContentPane().add(rtfs);
  210.                
  211.                 JRadioButton allformats = new JRadioButton("\u6240\u6709\u683C\u5F0F");
  212.                 allformats.addMouseListener(new MouseAdapter()
  213.                 {
  214.                         @Override
  215.                         public void mouseClicked(MouseEvent arg0)
  216.                         {
  217.                                 selformat=selallformats;
  218.                         }
  219.                 });
  220.                 searchallconfig.add(allformats);
  221.                 allformats.setBounds(568, 6, 80, 23);
  222.                 getContentPane().add(allformats);
  223.                
  224.                 JCheckBox chengtong = new JCheckBox("\u57CE\u901A\u7F51\u76D8");
  225.                 chengtong.setSelected(true);
  226.                 chengtong.setBounds(546, 68, 100, 23);
  227.                 getContentPane().add(chengtong);
  228.                
  229.                 JCheckBox xunleikuaichuan = new JCheckBox("\u8FC5\u96F7\u5FEB\u4F20");
  230.                 xunleikuaichuan.setSelected(true);
  231.                 xunleikuaichuan.setBounds(648, 68, 100, 23);
  232.                 getContentPane().add(xunleikuaichuan);
  233.                
  234.                 JCheckBox _360yunchuan = new JCheckBox("360\u4E91\u4F20");
  235.                 _360yunchuan.setSelected(true);
  236.                 _360yunchuan.setBounds(138, 91, 100, 23);
  237.                 getContentPane().add(_360yunchuan);
  238.                
  239.                 JCheckBox weipan1 = new JCheckBox("\u5A01\u76D81");
  240.                 weipan1.setSelected(true);
  241.                 weipan1.setBounds(240, 93, 100, 23);
  242.                 getContentPane().add(weipan1);
  243.                
  244.                 JCheckBox rayfile = new JCheckBox("rayfile\u7F51\u76D8");
  245.                 rayfile.setSelected(true);
  246.                 rayfile.setBounds(444, 91, 100, 23);
  247.                 getContentPane().add(rayfile);
  248.                
  249.                 JCheckBox xunzai = new JCheckBox("\u8FC5\u8F7D\u7F51\u76D8");
  250.                 xunzai.setSelected(true);
  251.                 xunzai.setBounds(546, 91, 100, 23);
  252.                 getContentPane().add(xunzai);
  253.                
  254.                 JCheckBox _163wangpan = new JCheckBox("163\u7F51\u76D8");
  255.                 _163wangpan.setSelected(true);
  256.                 _163wangpan.setBounds(648, 93, 100, 23);
  257.                 getContentPane().add(_163wangpan);
  258.                
  259.                 JCheckBox verycd = new JCheckBox("verycd\u79CD\u5B50");
  260.                 verycd.setBounds(138, 153, 100, 23);
  261.                 getContentPane().add(verycd);
  262.                
  263.                 JCheckBox ed2000 = new JCheckBox("ed2000\u79CD\u5B50");
  264.                 ed2000.setBounds(240, 153, 100, 23);
  265.                 getContentPane().add(ed2000);
  266.                
  267.                 JCheckBox xinlangaiwen = new JCheckBox("\u7231\u95EE\u5171\u4EAB");
  268.                 xinlangaiwen.setBounds(444, 153, 100, 23);
  269.                 getContentPane().add(xinlangaiwen);
  270.                
  271.                 JCheckBox weipan2 = new JCheckBox("\u5A01\u76D82");
  272.                 weipan2.setSelected(true);
  273.                 weipan2.setBounds(342, 93, 100, 23);
  274.                 getContentPane().add(weipan2);
  275.                
  276.                 JCheckBox qianyi = new JCheckBox("\u5343\u6613\u7F51\u76D8");
  277.                 qianyi.setSelected(true);
  278.                 qianyi.setBounds(138, 116, 100, 23);
  279.                 getContentPane().add(qianyi);
  280.                
  281.                 others = new JCheckBox("\u5F71\u89C6|\u8D44\u6599|\u5176\u4ED6");
  282.                 others.setBounds(6, 240, 118, 23);
  283.                 getContentPane().add(others);
  284.                
  285.                 JCheckBox bthome = new JCheckBox("bt\u4E4B\u5BB6");
  286.                 bthome.setBounds(342, 153, 100, 23);
  287.                 getContentPane().add(bthome);
  288.                
  289.                 JCheckBox dajialuntan = new JCheckBox("\u5927\u5BB6\u8BBA\u575B");
  290.                 dajialuntan.setBounds(546, 153, 100, 23);
  291.                 getContentPane().add(dajialuntan);
  292.                
  293.                 JCheckBox qiannao = new JCheckBox("\u5343\u8111\u4E0B\u8F7D");
  294.                 qiannao.setBounds(648, 153, 100, 23);
  295.                 getContentPane().add(qiannao);
  296.                
  297.                 JCheckBox _51cto = new JCheckBox("51cto\u4E0B\u8F7D");
  298.                 _51cto.setBounds(138, 178, 100, 23);
  299.                 getContentPane().add(_51cto);
  300.                
  301.                 JCheckBox csdn = new JCheckBox("CSDN\u4E0B\u8F7D");
  302.                 csdn.setBounds(240, 178, 100, 23);
  303.                 getContentPane().add(csdn);
  304.                
  305.                 JCheckBox xixi = new JCheckBox("\u897F\u897F\u4E0B\u8F7D");
  306.                 xixi.setBounds(342, 178, 100, 23);
  307.                 getContentPane().add(xixi);
  308.                
  309.                 JSeparator separator_3 = new JSeparator();
  310.                 separator_3.setForeground(Color.BLUE);
  311.                 separator_3.setBackground(Color.BLUE);
  312.                 separator_3.setBounds(0, 232, 764, 2);
  313.                 getContentPane().add(separator_3);
  314.                
  315.                 JCheckBox baiduwenku = new JCheckBox("\u767E\u5EA6\u6587\u5E93");
  316.                 baiduwenku.setBounds(240, 240, 100, 23);
  317.                 getContentPane().add(baiduwenku);
  318.                
  319.                 JCheckBox xuexiziliaoku = new JCheckBox("\u5B66\u4E60\u8D44\u6599\u5E93");
  320.                 xuexiziliaoku.setBounds(342, 240, 100, 23);
  321.                 getContentPane().add(xuexiziliaoku);
  322.                
  323.                 JCheckBox lanying = new JCheckBox("\u84DD\u5F71\u8BBA\u575B");
  324.                 lanying.setBounds(240, 290, 100, 23);
  325.                 getContentPane().add(lanying);
  326.                
  327.                 JCheckBox zhenhao = new JCheckBox("\u771F\u597D\u8BBA\u575B");
  328.                 zhenhao.setBounds(342, 290, 100, 23);
  329.                 getContentPane().add(zhenhao);
  330.                
  331.                 JCheckBox googlecode = new JCheckBox("googlecode");
  332.                 googlecode.setBounds(240, 340, 100, 23);
  333.                 getContentPane().add(googlecode);
  334.                
  335.                 JCheckBox pudn = new JCheckBox("pudn");
  336.                 pudn.setBounds(342, 340, 100, 23);
  337.                 getContentPane().add(pudn);
  338.                
  339.                 JCheckBox jiaobenzhijia = new JCheckBox("\u811A\u672C\u4E4B\u5BB6");
  340.                 jiaobenzhijia.setBounds(444, 240, 100, 23);
  341.                 getContentPane().add(jiaobenzhijia);
  342.                
  343.                 JLabel label_1 = new JLabel("\u8D44\u6599\uFF1A");
  344.                 label_1.setBounds(142, 242, 44, 19);
  345.                 getContentPane().add(label_1);
  346.                
  347.                 JLabel label_2 = new JLabel("\u7535\u5F71\uFF1A");
  348.                 label_2.setBounds(142, 292, 44, 19);
  349.                 getContentPane().add(label_2);
  350.                
  351.                 JLabel label_3 = new JLabel("\u4EE3\u7801\uFF1A");
  352.                 label_3.setBounds(142, 342, 44, 19);
  353.                 getContentPane().add(label_3);
  354.                
  355.                 JSeparator separator_4 = new JSeparator();
  356.                 separator_4.setForeground(Color.BLUE);
  357.                 separator_4.setBackground(Color.BLUE);
  358.                 separator_4.setBounds(0, 398, 764, 2);
  359.                 getContentPane().add(separator_4);
  360.                
  361.                 JButton search = new JButton("\u5F00\u59CB\u641C\u7D22");
  362.                 search.setBounds(648, 410, 116, 23);
  363.                 getContentPane().add(search);
  364.                
  365.                 ToSearch = new JTextField();
  366.                 ToSearch.setBounds(6, 411, 640, 21);
  367.                 getContentPane().add(ToSearch);
  368.                 ToSearch.setColumns(10);
  369.                
  370.                 JLabel lbllichao = new JLabel("\u4F5C\u8005\u4FE1\u606F:    lichao890427    qq:571652571    \u7FA4:124408915    lichao.890427@163.com  www.0xaa55.com");
  371.                 lbllichao.setForeground(Color.RED);
  372.                 lbllichao.setHorizontalAlignment(SwingConstants.LEFT);
  373.                 lbllichao.setBounds(6, 473, 560, 19);
  374.                 getContentPane().add(lbllichao);
  375.                
  376.                 JLabel label = new JLabel("\u641C\u7D22\u5173\u952E\u8BCD\u4F4D\u4E8E\uFF1A");
  377.                 label.setBounds(6, 448, 100, 15);
  378.                 getContentPane().add(label);
  379.                
  380.                 JRadioButton searchanywhere = new JRadioButton("\u7F51\u9875\u7684\u4EFB\u4F55\u5730\u65B9");
  381.                 searchanywhere.addMouseListener(new MouseAdapter()
  382.                 {
  383.                         @Override
  384.                         public void mouseClicked(MouseEvent arg0)
  385.                         {
  386.                                 seaplace=seaanywhere;
  387.                         }
  388.                 });
  389.                 searchplace.add(searchanywhere);
  390.                 searchanywhere.setBounds(130, 444, 128, 23);
  391.                 getContentPane().add(searchanywhere);
  392.                
  393.                 JRadioButton searchtitle = new JRadioButton("\u4EC5\u7F51\u9875\u7684\u6807\u9898\u4E2D");
  394.                 searchtitle.addMouseListener(new MouseAdapter()
  395.                 {
  396.                         @Override
  397.                         public void mouseClicked(MouseEvent arg0)
  398.                         {
  399.                                 seaplace=seatitle;
  400.                         }
  401.                 });
  402.                 searchplace.add(searchtitle);
  403.                 searchtitle.setSelected(true);
  404.                 searchtitle.setBounds(261, 444, 121, 23);
  405.                 getContentPane().add(searchtitle);
  406.                
  407.                 JRadioButton searchurl = new JRadioButton("\u4EC5\u7F51\u9875\u7684URL\u4E2D");
  408.                 searchurl.addMouseListener(new MouseAdapter()
  409.                 {
  410.                         @Override
  411.                         public void mouseClicked(MouseEvent arg0)
  412.                         {
  413.                                 seaplace=seaurl;
  414.                         }
  415.                 });
  416.                 searchplace.add(searchurl);
  417.                 searchurl.setBounds(385, 444, 121, 23);
  418.                 getContentPane().add(searchurl);
  419.                
  420.                 try
  421.                 {
  422.                         wangpanarray=new JCheckBox[]
  423.                         {
  424.                                 baidu,   _115wangpan, huawei1,  huawei2,  jinshankuaipan, lianxiang,
  425.                                 yimuhe,   namipan,  qianjunwanma, keleyun,  chengtong,  xunleikuaichuan,
  426.                                 _360yunchuan, weipan1,  weipan2,  rayfile,  xunzai,   _163wangpan,
  427.                                 qianyi,
  428.                         };
  429.                        
  430.                         websitearray=new JCheckBox[]
  431.                         {
  432.                                 verycd,   ed2000,   bthome,   xinlangaiwen, dajialuntan, qiannao,
  433.                                 _51cto,   csdn,   xixi,
  434.                         };
  435.                        
  436.                         otherarray=new JCheckBox[]
  437.                         {
  438.                                 baiduwenku,  xuexiziliaoku, jiaobenzhijia,
  439.                                 lanying,  zhenhao,
  440.                                 googlecode,  pudn,
  441.                         };
  442.                        
  443.                         for(int i=0;i<wangpanarray.length;i++)
  444.                         {
  445.                                 wangpanarray.addMouseListener(new MouseAdapter()
  446.                                 {
  447.                                         @Override
  448.                                         public void mouseClicked(MouseEvent arg0)
  449.                                         {
  450.                                                 allthings.setSelected(false);
  451.                                                 others.setSelected(false);
  452.                                         }
  453.                                 });
  454.                         }
  455.                        
  456.                         for(int i=0;i<websitearray.length;i++)
  457.                         {
  458.                                 websitearray.addMouseListener(new MouseAdapter()
  459.                                 {
  460.                                         @Override
  461.                                         public void mouseClicked(MouseEvent arg0)
  462.                                         {
  463.                                                 allthings.setSelected(false);
  464.                                                 others.setSelected(false);
  465.                                         }  
  466.                                 });
  467.                         }
  468.                        
  469.                         for(int i=0;i<otherarray.length;i++)
  470.                         {
  471.                                 otherarray.addMouseListener(new MouseAdapter()
  472.                                 {
  473.                                         @Override
  474.                                         public void mouseClicked(MouseEvent arg0)
  475.                                         {
  476.                                                 allthings.setSelected(false);
  477.                                                 others.setSelected(false);
  478.                                         }
  479.                                 });
  480.                         }
  481.                        
  482.                         allthings.addMouseListener(new MouseAdapter()
  483.                         {
  484.                                 @Override
  485.                                 public void mouseClicked(MouseEvent arg0)
  486.                                 {
  487.                                         if(allthings.isSelected())
  488.                                         {
  489.                                                 wangpan.setSelected(false);
  490.                                                 for(int i=0;i<wangpanarray.length;i++)
  491.                                                 {
  492.                                                         wangpanarray.setSelected(false);
  493.                                                 }
  494.                                                 wangzhanluntan.setSelected(false);
  495.                                                 for(int i=0;i<websitearray.length;i++)
  496.                                                 {
  497.                                                         websitearray.setSelected(false);
  498.                                                 }
  499.                                                 others.setSelected(false);
  500.                                                 for(int i=0;i<otherarray.length;i++)
  501.                                                 {
  502.                                                         otherarray.setSelected(false);
  503.                                                 }
  504.                                         }
  505.                                 }
  506.                         });
  507.                        
  508.                         wangpan.addMouseListener(new MouseAdapter()
  509.                         {
  510.                                 @Override
  511.                                 public void mouseClicked(MouseEvent arg0)
  512.                                 {
  513.                                         allthings.setSelected(false);
  514.                                         if(wangpan.isSelected())
  515.                                         {
  516.                                                 for(int i=0;i<wangpanarray.length;i++)
  517.                                                 {
  518.                                                         wangpanarray.setSelected(true);
  519.                                                 }
  520.                                         }
  521.                                         else
  522.                                         {
  523.                                                 for(int i=0;i<wangpanarray.length;i++)
  524.                                                 {
  525.                                                         wangpanarray.setSelected(false);
  526.                                                 }
  527.                                         }
  528.                                 }
  529.                         });
  530.                        
  531.                         wangzhanluntan.addMouseListener(new MouseAdapter()
  532.                         {
  533.                                 @Override
  534.                                 public void mouseClicked(MouseEvent arg0)
  535.                                 {
  536.                                         allthings.setSelected(false);
  537.                                         if(wangzhanluntan.isSelected())
  538.                                         {
  539.                                                 for(int i=0;i<websitearray.length;i++)
  540.                                                 {
  541.                                                         websitearray.setSelected(true);
  542.                                                 }
  543.                                         }
  544.                                         else
  545.                                         {
  546.                                                 for(int i=0;i<websitearray.length;i++)
  547.                                                 {
  548.                                                         websitearray.setSelected(false);
  549.                                                 }
  550.                                         }
  551.                                 }
  552.                         });
  553.                        
  554.                         others.addMouseListener(new MouseAdapter()
  555.                         {
  556.                                 @Override
  557.                                 public void mouseClicked(MouseEvent arg0)
  558.                                 {
  559.                                         allthings.setSelected(false);
  560.                                         if(others.isSelected())
  561.                                         {
  562.                                                 for(int i=0;i<otherarray.length;i++)
  563.                                                 {
  564.                                                         otherarray.setSelected(true);
  565.                                                 }
  566.                                         }
  567.                                         else
  568.                                         {
  569.                                                 for(int i=0;i<otherarray.length;i++)
  570.                                                 {
  571.                                                         otherarray.setSelected(false);
  572.                                                 }
  573.                                         }
  574.                                 }
  575.                         });
  576.                        
  577.                         search.addMouseListener(this);
  578.                 }
  579.                 catch(Exception e)
  580.                 {
  581.                         e.printStackTrace();
  582.                 }
  583.                
  584.                 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  585.                 setSize(784,547);
  586.                 setVisible(true);
  587.         }

  588.         public static void main(String[] args)
  589.         {
  590.                 try
  591.                 {
  592.                         DevineSearch cursearch=new DevineSearch();
  593.                         DevineSearch.result=new ResultList(cursearch);
  594.                 }
  595.                 catch(Exception e)
  596.                 {
  597.                         e.printStackTrace();
  598.                 }
  599.         }
  600.         @Override
  601.         public void mouseClicked(MouseEvent arg0)
  602.         {
  603.                 StopSearch=false;
  604.                 result.ClearDefaultTable();
  605.                
  606.                 try
  607.                 {
  608.                         String searchstring="http://www.baidu.com/s?q1="+ToSearch.getText()+"&q2=&q3=&q4=&rn=50&lm=0&ct=0&ft=";
  609.                         String seawhstring="&q5=1&q6=";
  610.                         if(seaplace == seaanywhere)
  611.                                 seawhstring="&q5=&q6=";
  612.                         else if(seaplace == seaurl)
  613.                                 seawhstring="&q5=2&q6=";
  614.                        
  615.                         if(allthings.isSelected())
  616.                         {
  617.                                 switch(selformat)
  618.                                 {
  619.                                         case selallhtmsandfiles:
  620.                                                 break;
  621.                                        
  622.                                         case selpdfs:
  623.                                                 searchstring+="pdf";
  624.                                                 break;
  625.                                        
  626.                                         case seldocs:
  627.                                                 searchstring+="doc";
  628.                                                 break;
  629.                                        
  630.                                         case selxlss:
  631.                                                 searchstring+="xls";
  632.                                                 break;
  633.                                        
  634.                                         case selppts:
  635.                                                 searchstring+="ppt";
  636.                                                 break;
  637.                                        
  638.                                         case selrtfs:
  639.                                                 searchstring+="rtf";
  640.                                                 break;
  641.                                        
  642.                                         case selallformats:
  643.                                                 searchstring+="all";
  644.                                                 break;
  645.                                        
  646.                                         default:
  647.                                                 break;
  648.                                 }
  649.                                 result.SearchOne(searchstring+seawhstring,true);
  650.                         }
  651.                         else if(wangpan.isSelected() || wangzhanluntan.isSelected() || others.isSelected())
  652.                         {
  653.                                 String wangpanarraystr[]=
  654.                                 {
  655.                                         "pan.baidu.com", "q.115.com",  "dl.dbank.com",  "dl.vmall.com",  "www.kuaipan.cn", "app.lenovo.com",
  656.                                         "www.yimuhe.com", "www.namipan.cc", "7958.com",   "www.colafile.com", "www.400gb.com", "kuai.xunlei.com",
  657.                                         "yunpan.cn",  "vdisk.cn",   "vdisk.weibo.com", "www.rayfile.com", "u.xunzai.com",  "www.163disk.com",
  658.                                         "1000eb.com",
  659.                                 };
  660.                                
  661.                                 String websitearraystr[]=
  662.                                 {
  663.                                         "www.verycd.com", "www.ed2000.com",  "www.btbbt.com", "ishare.iask.sina.com.cn", "club.topsage.com", "www.qiannao.com",
  664.                                         "down.51cto.com", "download.csdn.net", "www.cr173.com",
  665.                                 };
  666.                                
  667.                                 String otherarraystr[]=
  668.                                 {
  669.                                         "wenku.baidu.com", "www.xuexi111.com",  "www.jb51.net",
  670.                                         "www.blue08.cn", "www.chinazhw.com", "www.0xaa55.com"
  671.                                         "googlecode.com", "www.pudn.com",
  672.                                 };
  673.                                        
  674.                                 searchstring+=seawhstring;
  675.                                 for(int i=0;i<wangpanarray.length && !StopSearch;i++)
  676.                                 {
  677.                                         if(wangpanarray.isSelected())
  678.                                         {
  679.                                                 result.SearchOne(searchstring+wangpanarraystr,true);
  680.                                         }
  681.                                 }
  682.                                 for(int i=0;i<websitearray.length && !StopSearch;i++)
  683.                                 {
  684.                                         if(websitearray.isSelected())
  685.                                         {
  686.                                                 result.SearchOne(searchstring+websitearraystr,true);
  687.                                         }
  688.                                 }
  689.                                 for(int i=0;i<otherarray.length && !StopSearch;i++)
  690.                                 {
  691.                                         if(otherarray.isSelected())
  692.                                         {
  693.                                                 result.SearchOne(searchstring+otherarraystr,true);
  694.                                         }
  695.                                 }
  696.                         }
  697.                 }
  698.                 catch(Exception e)
  699.                 {
  700.                         e.printStackTrace();
  701.                 }
  702.         }
  703.         @Override
  704.         public void mouseEntered(MouseEvent arg0){}
  705.         @Override
  706.         public void mouseExited(MouseEvent arg0){}
  707.         @Override
  708.         public void mousePressed(MouseEvent arg0){}
  709.         @Override
  710.         public void mouseReleased(MouseEvent arg0){}
  711. }
复制代码
回复

使用道具 举报

307

主题

228

回帖

7343

积分

用户组: 真·技术宅

UID
2
精华
76
威望
291 点
宅币
5593 个
贡献
253 次
宅之契约
0 份
在线时间
948 小时
注册时间
2014-1-25
 楼主| 发表于 2014-2-20 13:34:46 | 显示全部楼层
  1. import java.awt.Rectangle;
  2. import java.awt.Toolkit;
  3. import java.awt.datatransfer.StringSelection;
  4. import java.awt.event.ComponentAdapter;
  5. import java.awt.event.ComponentEvent;
  6. import java.awt.event.MouseAdapter;
  7. import java.awt.event.MouseEvent;
  8. import java.awt.event.WindowAdapter;
  9. import java.awt.event.WindowEvent;
  10. import java.awt.event.WindowStateListener;
  11. import java.util.LinkedList;
  12. import java.util.Queue;
  13. import javax.swing.JButton;
  14. import javax.swing.JFrame;
  15. import javax.swing.JScrollPane;
  16. import javax.swing.JTable;
  17. import javax.swing.table.DefaultTableModel;
  18. import javax.swing.JLabel;
  19. import org.jsoup.Jsoup;
  20. import org.jsoup.nodes.Document;
  21. import org.jsoup.nodes.Element;
  22. import org.jsoup.select.Elements;
  23. public class ResultList extends JFrame
  24. {
  25.         /**
  26.           *
  27.           */
  28.         private static final long serialVersionUID = -7586074484755866311L;
  29.         public JTable table=null;
  30.         private JScrollPane sp=null;
  31.         private JButton copyaddress=null;
  32.         private JButton stop=null;
  33.         private int index=0;
  34.         private Queue<MySearchThread> threadqueue=null;
  35.         private JLabel state=null;
  36.         private String errorstring=null;

  37.         class MySearchThread extends Thread
  38.         {
  39.                 private String cururl=null;
  40.                 private boolean findsub=false;
  41.                 public MySearchThread(String cururl,boolean findsub)
  42.                 {
  43.                         super();
  44.                         this.cururl=cururl;
  45.                         this.findsub=findsub;
  46.                         System.out.println(cururl);
  47.                 }
  48.                
  49.                 @Override
  50.                 public void run()
  51.                 {
  52.                         errorstring=null;
  53.                         try
  54.                         {
  55.                                 if(DevineSearch.StopSearch)
  56.                                 {
  57.                                         return;
  58.                                 }
  59.                                
  60.                                 Document doc=Jsoup.connect(cururl).timeout(0).get();//源1  
  61.                                 Elements curresult=doc.select("table.result");
  62.                                 for(Element e:curresult)
  63.                                 {
  64.                                         String[] arr=new String[]{""+index,"","",""};
  65.                                         Elements rt1=e.select(".t a");
  66.                                         if(!rt1.isEmpty())
  67.                                         {
  68.                                                 arr[1]=RemoveEm(rt1.get(0).text());
  69.                                                 arr[3]=RemoveEm(rt1.get(0).attr("href"));
  70.                                         }
  71.                                         rt1=e.select(".c-abstract");
  72.                                         if(!rt1.isEmpty())
  73.                                         {
  74.                                                 arr[2]=RemoveEm(rt1.get(0).text());
  75.                                         }
  76.                                         DefaultTableModel tableModel=(DefaultTableModel)table.getModel();
  77.                                         tableModel.addRow(arr);
  78.                                         index++;
  79.                                 }  
  80.                                
  81.                                 if(findsub)
  82.                                 {
  83.                                         Elements otherresults=doc.select("p#page a");
  84.                                         for(Element other:otherresults)
  85.                                         {
  86.                                                 if(!other.text().contains("下一页"));
  87.                                                 {
  88.                                                         threadqueue.add(new MySearchThread(other.attr("abs:href"),false));
  89.                                                 }
  90.                                         }
  91.                                 }
  92.                         }
  93.                         catch(Exception e)
  94.                         {
  95.                                 e.printStackTrace();
  96.                                 errorstring=e.getCause().toString();
  97.                         }
  98.                 }
  99.         }

  100.         public void ClearDefaultTable()
  101.         {
  102.                 index=0;
  103.                 if(table == null)
  104.                         return;
  105.                 table.setModel(new DefaultTableModel(
  106.                                 new Object[][] {
  107.                                 },
  108.                                 new String[] {
  109.                                         "\u5E8F\u53F7", "\u6807\u9898", "\u5176\u4ED6\u4FE1\u606F", "\u7F51\u5740"
  110.                                 }
  111.                         ));
  112.         }

  113.         public ResultList(DevineSearch father)
  114.         {
  115.                 super("搜索结果");
  116.                 setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  117.                
  118.                 addWindowListener(new WindowAdapter()
  119.                 {
  120.                         @Override
  121.                         public void windowClosing(WindowEvent arg0)
  122.                         {
  123.                                 DevineSearch.result=null;
  124.                                 DevineSearch.StopSearch=true;
  125.                         }
  126.                 });
  127.                 addWindowStateListener(new WindowStateListener()
  128.                 {
  129.                         @Override
  130.                         public void windowStateChanged(WindowEvent e)
  131.                         {  
  132.                                 Rectangle rtb=getContentPane().getBounds();
  133.                                 if(sp != null)
  134.                                 {
  135.                                         Rectangle rta=sp.getBounds();
  136.                                         sp.setBounds(rta.x,rta.y,rtb.width,rtb.height-30);
  137.                                         table.setBounds(rta.x,rta.y,rtb.width,rtb.height-30);
  138.                                 }
  139.                                 if(copyaddress != null)
  140.                                 {
  141.                                         Rectangle rta=copyaddress.getBounds();
  142.                                         copyaddress.setBounds(rta.x,rtb.y+rtb.height-rta.height,rta.width,rta.height);
  143.                                 }
  144.                                 if(stop != null)
  145.                                 {
  146.                                         Rectangle rta=stop.getBounds();
  147.                                         stop.setBounds(rta.x,rtb.y+rtb.height-rta.height,rta.width,rta.height);
  148.                                 }
  149.                                 if(state != null)
  150.                                 {
  151.                                         Rectangle rta=state.getBounds();
  152.                                         state.setBounds(rta.x,rtb.y+rtb.height-rta.height,rta.width,rta.height);
  153.                                 }
  154.                         }
  155.                 });
  156.                 addComponentListener(new ComponentAdapter()
  157.                 {
  158.                         @Override
  159.                         public void componentResized(ComponentEvent arg0)
  160.                         {
  161.                                 Rectangle rtb=getContentPane().getBounds();
  162.                                 if(sp != null)
  163.                                 {
  164.                                         Rectangle rta=sp.getBounds();
  165.                                         sp.setBounds(rta.x,rta.y,rtb.width,rtb.height-30);
  166.                                 }
  167.                                 if(copyaddress != null)
  168.                                 {
  169.                                         Rectangle rta=copyaddress.getBounds();
  170.                                         copyaddress.setBounds(rta.x,rtb.y+rtb.height-rta.height,rta.width,rta.height);
  171.                                 }
  172.                                 if(stop != null)
  173.                                 {
  174.                                         Rectangle rta=stop.getBounds();
  175.                                         stop.setBounds(rta.x,rtb.y+rtb.height-rta.height,rta.width,rta.height);
  176.                                 }
  177.                                 if(state != null)
  178.                                 {
  179.                                         Rectangle rta=state.getBounds();
  180.                                         state.setBounds(rta.x,rtb.y+rtb.height-rta.height,rta.width,rta.height);   
  181.                                 }
  182.                         }
  183.                 });
  184.                
  185.                 setTitle("搜索结果");
  186.                 getContentPane().setLayout(null);
  187.                
  188.                 stop = new JButton("\u505C\u6B62\u641C\u7D22");
  189.                 stop.setBounds(32, 339, 93, 23);
  190.                 getContentPane().add(stop);
  191.                
  192.                 copyaddress = new JButton("\u590D\u5236\u94FE\u63A5");
  193.                 copyaddress.setBounds(150, 339, 93, 23);
  194.                 getContentPane().add(copyaddress);
  195.                
  196.                 table = new JTable();
  197.                 ClearDefaultTable();
  198.                 table.getColumnModel().getColumn(0).setPreferredWidth(50);
  199.                 table.getColumnModel().getColumn(0).setMinWidth(50);
  200.                 table.getColumnModel().getColumn(1).setPreferredWidth(250);
  201.                 table.getColumnModel().getColumn(2).setPreferredWidth(200);
  202.                 table.getColumnModel().getColumn(3).setPreferredWidth(200);
  203.                 table.setBounds(10, 10, 564, 288);
  204.                 sp=new JScrollPane(table);
  205.                 sp.setBounds(0, 0, 584, 329);
  206.                 getContentPane().add(sp);
  207.                
  208.                 state = new JLabel("");
  209.                 state.setBounds(270, 339, 271, 19);
  210.                 getContentPane().add(state);
  211.                
  212.                 try
  213.                 {
  214.                         stop.addMouseListener(new MouseAdapter()
  215.                         {
  216.                                 @Override
  217.                                 public void mouseClicked(MouseEvent arg0)
  218.                                 {
  219.                                         DevineSearch.StopSearch=true;
  220.                                 }
  221.                         });
  222.                        
  223.                         copyaddress.addMouseListener(new MouseAdapter()
  224.                         {
  225.                                 @Override
  226.                                 public void mouseClicked(MouseEvent arg0)
  227.                                 {
  228.                                         if(table.getSelectedRowCount() > 0)
  229.                                         {
  230.                                         String cursel=(String)table.getValueAt(table.getSelectedRow(),3);
  231.                                         Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(cursel),null);   
  232.                                         }
  233.                                 }
  234.                         });
  235.                        
  236.                 }
  237.                 catch(Exception e)
  238.                 {
  239.                         e.printStackTrace();
  240.                 }
  241.                 setSize(600,400);
  242.                 setVisible(true);
  243.                
  244.                 threadqueue=new LinkedList<MySearchThread>();
  245.                 new Thread()
  246.                 {
  247.                         @Override
  248.                         public void run()
  249.                         {
  250.                                 try
  251.                                 {
  252.                                         while(true)
  253.                                         {
  254.                                         Thread.sleep(100);
  255.                                         if(!threadqueue.isEmpty())
  256.                                         {
  257.                                                 state.setText("处理中");
  258.                                                 MySearchThread cur=threadqueue.poll();
  259.                                                 cur.start();
  260.                                                 cur.join();
  261.                                                 if(errorstring == null)
  262.                                         state.setText("处理完毕");
  263.                                                 else
  264.                                         state.setText("出错:"+errorstring);
  265.                                         }
  266.                                         else
  267.                                                 state.setText("空闲");
  268.                                         }
  269.                                 }
  270.                                 catch(Exception e)
  271.                                 {
  272.                                         e.printStackTrace();
  273.                                 }
  274.                         }
  275.                 }.start();
  276.         }

  277.         public void SearchOne(String url,boolean findsub)
  278.         {
  279.                 threadqueue.add(new MySearchThread(url,true));
  280.         }

  281.         private String RemoveEm(String src)
  282.         {
  283.                 src.replace("<em>","");
  284.                 src.replace("</em>","");
  285.                 return src;
  286.         }

  287.         public static void main(String[] args)
  288.         {
  289.                 new ResultList(null).SearchOne("",true);
  290.         }
  291. }
复制代码

回复 赞! 靠!

使用道具 举报

4

主题

5

回帖

87

积分

用户组: 小·技术宅

UID
97
精华
0
威望
2 点
宅币
64 个
贡献
10 次
宅之契约
0 份
在线时间
2 小时
注册时间
2014-2-28
发表于 2014-4-7 11:22:20 | 显示全部楼层
2天写 1000行代码真是不容易, 后面那句我假装没听见....O(∩_∩)O哈哈~
回复 赞! 靠!

使用道具 举报

0

主题

5

回帖

45

积分

用户组: 初·技术宅

UID
2119
精华
0
威望
2 点
宅币
36 个
贡献
0 次
宅之契约
0 份
在线时间
3 小时
注册时间
2016-12-12
发表于 2018-4-20 16:16:42 | 显示全部楼层
现在百度云或者其它东西的资源或许发生变化了,求更
回复 赞! 靠!

使用道具 举报

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-4-25 07:33 , Processed in 0.056336 second(s), 34 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表