| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
yne7
9年前发布

Java网络爬虫:kamike.collect

Another Simple Crawler 又一个网络爬虫,可以支持代理服务器的KX上网爬取。

1.数据存在mysql当中。

2.使用时,先修改web-inf/config.ini的数据链接相关信息,主要是数据库名和用户名和密码

3.然后访问http://127.0.0.1/fetch/install 链接,自动创建数据库表

4.修改src\java\cn\exinhua\fetch中的RestServlet.java文件:

   FetchInst.getInstance().running=true;        Fetch fetch = new Fetch();        fetch.setUrl("http://www.washingtonpost.com/");         fetch.setDepth(3);         RegexRule regexRule = new RegexRule();         regexRule.addNegative(".*#.*");         regexRule.addNegative(".*png.*");         regexRule.addNegative(".*jpg.*");         regexRule.addNegative(".*gif.*");         regexRule.addNegative(".*js.*");         regexRule.addNegative(".*css.*");         regexRule.addPositive(".*php.*");         regexRule.addPositive(".*html.*");         regexRule.addPositive(".*htm.*");         Fetcher fetcher = new Fetcher(fetch);         fetcher.setProxyAuth(true);         fetcher.setRegexRule(regexRule);         List<Fetcher> fetchers = new ArrayList<>();         fetchers.add(fetcher);      FetchUtils.start(fetchers);            将其配置为需要的参数,然后访问http://127.0.0.1/fetch/fetch启动爬取         代理的配置在Fetch.java文件中:      protected int status;     protected boolean resumable = false;     protected RegexRule regexRule = new RegexRule();  protected ArrayList<String> seeds = new ArrayList<String>();  protected Fetch fetch;     protected String proxyUrl="127.0.0.1";  protected int proxyPort=4444;  protected String proxyUsername="hkg";  protected String proxyPassword="dennis";  protected boolean proxyAuth=false;

5.访问http://127.0.0.1/fetch/suspend可以停止爬取



项目主页:
http://www.open-open.com/lib/view/home/1427706459709

 本文由用户 yne7 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1427706459709.html
网络爬虫 kamike.collect