Giter Site home page Giter Site logo

crawler's Introduction

懒惰的追小说者:一个自动推送最新更新的小说内容的小应用

A crawler to crawl a network novel. It listens and dowloads the new updating section of the novel automatically.


需求:

本人在追两部小说,《大主宰》和《斗罗大陆3-龙王传说》,每过几个小时就去打开网页,点击bookmark,看看有没有更新。现在的需求是:我不需要用浏览器查看有没有更新,只要这两部小说更新了,这个应用就自动推送到我的手机上并提醒我。

思路:

写一个定时的应用,每15分钟访问一下相应的小说网页,如果有更新的小说章节,就下载下来,编辑好格式,发到我的qq邮箱上面。

实现

  • 语言:java

  • 服务器:腾讯云

  • 工具:putty,intelij IDEA

  • 发送邮件

    工具包:

<dependency>
  <groupId>javax.mail</groupId>
  <artifactId>mail</artifactId>
  <version>1.4.7</version>
</dependency>

本人使用网易的邮箱向qq邮箱发送邮件。需要注册一个网易邮箱,登录进去,开启SMTP服务,具体可参考

  • 如何实现程序定时

    public static void main(String[] args) {
            Runnable runnable = new Runnable() {
                public void run() {
                    new NovelOfDomination().doBusiness();
                    new DragonNovelDriver().doBusiness();
                }
            };
    
            ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
            service.scheduleAtFixedRate(runnable, 1, 900, TimeUnit.SECONDS);
        }
    

    上面的程序是本应用的主函数。定时的代码就是通过ScheduledExecutorService这个类实现的。

  • 部署:

    把程序打包成jar包,使用WinSCP.exe或者SSH客户端把jar包上传到服务器上面,使用下面命令运行:

    nohup java -cp Crawler.jar com.huai.driver.NovelMain&
    

    nohup命令的简单解释可以参考:http://blog.csdn.net/liangyihuai/article/details/55006719

这样子,就部署完成了。

注意:本人把源码中的网易邮箱和qq邮箱注释成XXX了,需要读者修改成自己的。

crawler's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.