网络爬虫Java实现原理

loading 分享 2026-7-20 下载文档

public class CheckLinks extends javax.swing.JFrame implements Runnable,ISpiderReportable {

/**

* The constructor. Perform setup here. */

public CheckLinks() {

//{{INIT_CONTROLS

setTitle(\Broken Links\ getContentPane().setLayout(null); setSize(405,288); setVisible(true);

label1.setText(\a URL:\ getContentPane().add(label1); label1.setBounds(12,12,84,12); begin.setText(\

begin.setActionCommand(\ getContentPane().add(begin); begin.setBounds(12,36,84,24); getContentPane().add(url); url.setBounds(108,36,288,24); errorScroll.setAutoscrolls(true);

errorScroll.setHorizontalScrollBarPolicy(javax.swing.

ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); errorScroll.setVerticalScrollBarPolicy(javax.swing.

ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); errorScroll.setOpaque(true); getContentPane().add(errorScroll); errorScroll.setBounds(12,120,384,156);

errors.setEditable(false);

errorScroll.getViewport().add(errors); errors.setBounds(0,0,366,138);

current.setText(\Processing: \ getContentPane().add(current); current.setBounds(12,72,384,12); goodLinksLabel.setText(\Links: 0\ getContentPane().add(goodLinksLabel); goodLinksLabel.setBounds(12,96,192,12); badLinksLabel.setText(\Links: 0\ getContentPane().add(badLinksLabel); badLinksLabel.setBounds(216,96,96,12); //}}

//{{INIT_MENUS //}}

//{{REGISTER_LISTENERS

SymAction lSymAction = new SymAction(); begin.addActionListener(lSymAction); //}} }

/**

* Main method for the application *

* @param args Not used */

static public void main(String args[]) {

(new CheckLinks()).setVisible(true); }

/**

* Add notifications. */

public void addNotify() {

// Record the size of the window prior to calling parent's // addNotify.

Dimension size = getSize();

super.addNotify();

if ( frameSizeAdjusted ) return;

frameSizeAdjusted = true;

// Adjust size of frame according to the insets and menu bar Insets insets = getInsets();

javax.swing.JMenuBar menuBar = getRootPane().getJMenuBar(); int menuBarHeight = 0; if ( menuBar != null )

menuBarHeight = menuBar.getPreferredSize().height; setSize(insets.left + insets.right + size.width, insets.top + insets.bottom + size.height + menuBarHeight); }

// Used by addNotify

boolean frameSizeAdjusted = false;

//{{DECLARE_CONTROLS

javax.swing.JLabel label1 = new javax.swing.JLabel();

/**

* The begin or cancel button */

javax.swing.JButton begin = new javax.swing.JButton();

/**

* The URL being processed */

javax.swing.JTextField url = new javax.swing.JTextField();

/**

* Scroll the errors. */

javax.swing.JScrollPane errorScroll = new javax.swing.JScrollPane();

/**

* A place to store the errors created */

javax.swing.JTextArea errors = new javax.swing.JTextArea(); javax.swing.JLabel current = new javax.swing.JLabel();

javax.swing.JLabel goodLinksLabel = new javax.swing.JLabel(); javax.swing.JLabel badLinksLabel = new javax.swing.JLabel(); //}}

//{{DECLARE_MENUS //}}

/**

* The background spider thread */

protected Thread backgroundThread;

/**

* The spider object being used */

protected Spider spider;

/**

* The URL that the spider began with */

protected URL base;

/**

* How many bad links have been found */

protected int badLinksCount = 0;

/**

* How many good links have been found */

protected int goodLinksCount = 0;

/**

* Internal class used to dispatch events *

* @author wuhailin * @version 1.0 */

class SymAction implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent event) {

Object object = event.getSource(); if ( object == begin )


网络爬虫Java实现原理.doc 将本文的Word文档下载到电脑
搜索更多关于: 网络爬虫Java实现原理 的文档
相关推荐
相关阅读