Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
code4craft committed Apr 25, 2014
1 parent 3a666fc commit 17e95f2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Thread pool for workers.<br></br>
* Use {@link java.util.concurrent.ExecutorService} as inner implement. <br></br>
* New feature: <br></br>
* 1. Block when thread pool is full to avoid poll many urls but not process. <br></br>
* 1. Block when thread pool is full to avoid poll many urls without process. <br></br>
* 2. Count of thread alive for monitor.
*
* @author [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.processor.PageProcessor;
import us.codecraft.webmagic.utils.Experimental;

import java.util.List;

/**
* @author [email protected] <br>
*/
@Experimental
public class ConfigurablePageProcessor implements PageProcessor {

private Site site;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import us.codecraft.webmagic.Request;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.SpiderListener;
import us.codecraft.webmagic.processor.example.GithubRepoPageProcessor;
import us.codecraft.webmagic.processor.example.OschinaBlogPageProcessor;
import us.codecraft.webmagic.utils.Experimental;
import us.codecraft.webmagic.utils.IPUtils;

import javax.management.JMException;
Expand All @@ -30,6 +29,7 @@
* @author [email protected]
* @since 0.5.0
*/
@Experimental
public class SpiderMonitor {

private enum Type {
Expand Down Expand Up @@ -226,22 +226,4 @@ public SpiderMonitor jmxStart(String jndiServer, int rmiPort) throws IOException
return this;
}

public static void main(String[] args) throws Exception {

Spider oschinaSpider = Spider.create(new OschinaBlogPageProcessor())
.addUrl("http://my.oschina.net/flashsword/blog").thread(2);
Spider githubSpider = Spider.create(new GithubRepoPageProcessor())
.addUrl("https://github.com/code4craft");

SpiderMonitor spiderMonitor = new SpiderMonitor();
spiderMonitor.register(oschinaSpider, githubSpider);
//If you want to connect it from remote, use spiderMonitor.server().jmxStart();
//ONLY ONE server can start for a machine.
//Others will be registered
spiderMonitor.server().jmxStart();
oschinaSpider.start();
githubSpider.thread(10).start();

}

}

0 comments on commit 17e95f2

Please sign in to comment.