Code Monkey home page Code Monkey logo

amazon-bookmonitor's Introduction

亚马逊图书监控爬虫

最近买了台Kindle,感觉亚马逊上的图书资源质量挺好,还时不时地会有价格低但质量高的书出售,但限于亚马逊并没有很好的优惠提醒功能,自己天天盯着又很累。于是,我自己写了一个基于Java的亚马逊图书监控的简单爬虫,只要出现特别优惠的书便会自动给指定的邮箱发邮件。

基本功能:

  • 监控销量排行榜前50名的图书价格,若出现价格低于设定值的图书,则发送邮件通知。
  • 带有数据缓存功能,比如持续几天的优惠只会在一开始时通知一次,并不会在每次抓取时都通知。
  • 可以通过配置文件(setting.conf)动态更改邮件和监控的设置。
  • 报错信息会保存在ErrLog.txt中,一般的日志会保存在Log.txt中。

配置文件内容

第一次运行需要修改配合文件且配置文件要位于项目的根目录或者jar包的同级目录下,下面介绍一下配置文件的配置项

  • 邮箱设置
    • Debug:邮件发送的debug开关,0为关,1为开,开启后会在日志文件记录发送邮件的日志
    • SmtpHost:邮箱的smtp服务器,例如QQ邮箱就是smtp.qq.com
    • Sender:发送邮件的账号
    • AuthCode:邮件发送账号的授权码(相当于密码),可以在各大邮箱的设置里面找到
    • SenderNickName:邮件发送者的别名
    • Receiver:收件人,若发给自己则与发件人一致
  • 监控设置
    • LowerThan:监控的价格
    • IntervalTime:监控的时间间隔(单位为小时),每过一个周期就看一下有没有优惠,
    • ValidTime:数据的有效时间(单位为天),也可以说是缓存时间,已经通知的优惠信息在该时间内不会再次通知

部署

首先,一定要开启邮箱的SMTP服务,否则邮件无法正常发送

  • 源码:源码拿下来改下配置文件、添加依赖包路径(发送邮件用了JavaMail,位于lib目录下)应该就可以用了。
  • Jar包:为了解决包的依赖问题,我把项目打成Jar包(位于release目录下)。在windows下运行的命令java -Dfile.encoding=UTF-8 -jar jar包的位置,中间UTF-8那个参数不加会乱码;linux下的运行命令:java -jar jar包的位置,若想在后台运行可以百度一下nohup命令的用法。

amazon-bookmonitor's People

Contributors

horvey avatar

Watchers

James Cloos 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.