public static Dao dao;
public static void main(String[] args) {
ds = new DruidDataSource();
ds.setDriverClassName("com.mysql.jdbc.Driver");
ds.setUrl("jdbc:mysql://192.168.0.255:3306/youfang?useUnicode=true&characterEncoding=utf-8");
ds.setUsername("root");
ds.setPassword("");
dao = new NutDao(ds);
MyRedisScheduler myRedisScheduler = new MyRedisScheduler("192.168.0.253");
Spider spider =OOSpider.create(
Site.me()
.setDomain("www.xxx.cn")
.setCharset("utf-8")
.setSleepTime(3000)
.setTimeOut(5000)
.setUserAgent(
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"),
new PageModelPipeline<Object>() {
public void process(Object o, Task task) {
//System.out.println(o);
}
}, DiBaoSecondHouse.class)
.addUrl("http://www.xxx.cn/abb/1_0_0_1/ ")
.scheduler(myRedisScheduler);
myRedisScheduler.pushRestartQueen(new Request("http://www.xxx.cn/abb/1_0_0_1/ "));
spider.thread(3).runAsync();
System.out.println("爬虫结束---");
//ds.close();
System.out.println("数据库关闭---");
}
0 回复
添加回复
请先登陆