package jschrj.lyf;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.PrintStream;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.EmptyBorder;
import jschrj.spider.SpiderTool;
import jschrj.widget.ConsoleTextArea;
import javax.swing.JTextPane;
import java.awt.ScrollPane;
import java.awt.TextArea;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import java.awt.Window.Type;
import java.awt.Component;
/**
* 程序 入口
* @author lyf 2018/07/09
*/
public class Spider extends JFrame {
private JPanel contentPane;
private JTextField txtUrl;
private JTextField txtListRule;
private JTextField txtPageRule;
private JTextField txtDtxt;
private JTextField txtThreadNum;
private ConsoleTextArea textArea_1 = null;
private JTextArea txtContent;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Spider frame = new Spider();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Spider() {
setResizable(false);
setTitle("爬虫工具");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(400, 100, 650, 620);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblNewLabel = new JLabel("抓取地址");
lblNewLabel.setFont(new Font("黑体", Font.PLAIN, 16));
JLabel lblNewLabel_1 = new JLabel("列表规则");
lblNewLabel_1.setFont(new Font("黑体", Font.PLAIN, 16));
JLabel label = new JLabel("页面规则");
label.setFont(new Font("黑体", Font.PLAIN, 16));
JLabel label_1 = new JLabel("抓取内容");
label_1.setFont(new Font("黑体", Font.PLAIN, 16));
JScrollPane scrollPane = new JScrollPane();
JScrollPane scrollPane_2 = new JScrollPane();
txtUrl = new JTextField();
txtUrl.setFont(new Font("黑体", Font.PLAIN, 12));
txtUrl.setText("http://bbs.huainet.com/forum.php");
txtUrl.setColumns(10);
txtListRule = new JTextField();
txtListRule.setFont(new Font("黑体", Font.PLAIN, 12));
txtListRule.setText("http://bbs.huainet.com/forum-[0-9]{1,3}-[0-9]{1,3}.html");
txtListRule.setColumns(10);
txtPageRule = new JTextField();
txtPageRule.setFont(new Font("黑体", Font.PLAIN, 12));
txtPageRule.setText("http://bbs.huainet.com/thread-[0-9]{1,12}-1-[0-9]{1,9}.html");
txtPageRule.setColumns(10);
JLabel lblNewLabel_2 = new JLabel("存放地址");
lblNewLabel_2.setFont(new Font("黑体", Font.PLAIN, 16));
txtDtxt = new JTextField();
txtDtxt.setFont(new Font("黑体", Font.PLAIN, 12));
txtDtxt.setText("D:\\淮水安澜.txt");
txtDtxt.setColumns(10);
JButton btnStart = new JButton("开始");
btnStart.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String url = txtUrl.getText();
String txtpath = txtDtxt.getText();
String listRule = txtListRule.getText();
String pageRule = txtPageRule.getText();
String content = txtContent.getText();
String num = txtThreadNum.getText();
SpiderTool.start(url,txtpath,listRule,pageRule,content,num);
// JOptionPane.showMessageDialog(null, "瞎点啥!", "标题", JOptionPane.WARNING_MESSAGE);
}
});
btnStart.setFont(new Font("黑体", Font.PLAIN, 16));
JLabel label_2 = new JLabel("线程数");
label_2.setFont(new Font("黑体", Font.PLAIN, 16));
txtThreadNum = new JTextField();
txtThreadNum.setFont(new Font("黑体", Font.PLAIN, 12));
txtThreadNum.setText("4");
txtThreadNum.setColumns(10);
JButton btnPause = new JButton("暂停");
btnPause.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SpiderTool.stop();
}
});
btnPause.setFont(new Font("黑体", Font.PLAIN, 16));
JButton btnContinue = new JButton("继续");
btnContinue.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SpiderTool.restart();
}
});
btnContinue.setFont(new Font("黑体", Font.PLAIN, 16));
JButton btnClear = new JButton("清空");
btnClear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textArea_1.setText("");
}
});
btnClear.setFont(new Font("黑体", Font.PLAIN, 16));
JScrollPane scrollPane_1 = new JScrollPane();
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(19)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(scrollPane_2, GroupLayout.PREFERRED_SIZE, 590, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addComponent(label_2)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(lblNewLabel)
.addComponent(lblNewLabel_1)
.addComponent(label)
.addComponent(label_1)
.addComponent(lblNewLabel_2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGap(21)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(txtThreadNum, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnStart)
.addGap(9)
.addComponent(btnPause)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnContinue)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnClear)
.addContainerGap())
.addComponent(scrollPane, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addComponent(txtListRule, 504, 504, Short.MAX_VALUE)
.addComponent(txtUrl, 504, 504, Short.MAX_VALUE)
.addComponent(txtPageRule, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE)
.addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE)
.addComponent(txtDtxt, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE))
.addGap(237))))))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(28)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel)
.addComponent(txtUrl, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel_1)
.addComponent(txtListRule, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(Componen
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
demo.rar (47个子文件)
com
pom.xml 1KB
target
test-classes
jschrj
lyf
com
classes
META-INF
maven
jschrj.lyf
com
pom.xml 1KB
pom.properties 198B
MANIFEST.MF 115B
log4j.properties 560B
jschrj
tools
DBHelper.class 2KB
MyPipeline.class 3KB
bean
WlyqBean.class 2KB
lyf
Spider$3.class 679B
Spider$4.class 682B
Spider$5.class 802B
Spider$2.class 1KB
SpiderForSql.class 8KB
SpiderForSql$2.class 2KB
SpiderForSql$5.class 845B
SpiderForSql$1.class 722B
SpiderForSql$3.class 721B
SpiderForSql$4.class 724B
Spider$1.class 692B
Spider.class 8KB
spider
SpiderTool.class 4KB
SpiderToolForSql.class 5KB
widget
LoopedStreams$3.class 1KB
LoopedStreams$1.class 925B
ConsoleTextArea.class 2KB
LoopedStreams.class 2KB
ConsoleTextArea$1.class 2KB
LoopedStreams$2.class 788B
libs
mysql-connector-java-5.1.39-bin.jar 966KB
.settings
org.eclipse.m2e.core.prefs 90B
org.eclipse.core.resources.prefs 119B
org.eclipse.jdt.core.prefs 243B
jgoodies-forms-1.8.0.jar 116KB
src
test
java
jschrj
lyf
com
main
java
log4j.properties 560B
jschrj
tools
MyPipeline.java 2KB
DBHelper.java 2KB
bean
WlyqBean.java 2KB
lyf
Spider.java 10KB
SpiderForSql.java 10KB
spider
SpiderToolForSql.java 4KB
SpiderTool.java 3KB
widget
ConsoleTextArea.java 2KB
LoopedStreams.java 2KB
libs
mysql-connector-java-5.1.39-bin.jar 966KB
.project 555B
.classpath 1KB
miglayout15-swing.jar 75KB
共 47 条
- 1
资源评论
末日之花
- 粉丝: 4
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功