File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66#### 配置参数
77参考:application.yml文件配置即可
88```
9- # 配置自己的server酱key
10- # 参考地址:http://sc.ftqq.com/3.version
11- key: b082eb2****
12- # 什么值得买爆料人id:
13- # 参考:https://zhiyou.smzdm.com/member/9687682701/baoliao/
14- uid: 9687682701
15- # server酱有每天次数(重要重要重要)限制建议:60秒钟一次,已经做了重复限制,相同商品不会重复推送
16- corn: 0/59 * * * * ?
17- #测试频率:十秒一次
9+ key:
10+ #支持两种配置:【pushPlus】或者【serverJ】,二选一
11+ #pushPlus参考:http://pushplus.hxtrip.com/,不限制次数,不用github账号
12+ #serverJ参考:http://sc.ftqq.com/3.version ,需要github账号,限制次数
13+ type: pushPlus
14+ # 对应平台的key
15+ value: SCU68113********
16+ #爆料人id:https://zhiyou.smzdm.com/member/9687682701/baoliao/ 参考这个链接
17+ blr:
18+ #支持多个爆料人id,用英文都好隔开即可
19+ uids: 9687682701,2031093162,3050600933
20+ # 频率十秒一次 ,
21+ #corn: 0/10 * * * * ?
22+ # 三十秒一次
1823#corn: 0/30 * * * * ?
24+ # 一分钟一次
25+ corn: 0/59 * * * * ?
1926```
2027
21- #### server酱参数
22- 文档之间看官网即可
28+ #### serverJ酱参数
29+ 文档之间看官网即可(需要github账号,限制次数)
30+
31+ 文档:http://sc.ftqq.com/3.version
32+
33+ https://s3.ax1x.com/2020/12/29/rHchjg.png
34+
35+ ![ serverJ酱参数] ( https://s3.ax1x.com/2020/12/29/rHchjg.png )
36+
37+ #### pushPlus参数
38+
39+ 文档之间看官网即可(不限制次数,不用github账号),比较推荐这个更简单点。
40+
41+ 文档:http://pushplus.hxtrip.com/
2342
24- http://sc.ftqq.com/3.version
43+ https://s3.ax1x.com/2020/12/29/rHguVA.png
44+ ![ serverJ酱参数] ( https://s3.ax1x.com/2020/12/29/rHguVA.png )
2545
2646#### 启动
2747ZdmPushApplication.class
Original file line number Diff line number Diff line change 66import us .codecraft .webmagic .Site ;
77import us .codecraft .webmagic .processor .PageProcessor ;
88
9+ import java .util .HashMap ;
10+ import java .util .Map ;
11+
912/**
1013 * @Description
1114 * @Author Grt
@@ -18,7 +21,7 @@ public class ZdmPageProcessor implements PageProcessor {
1821 /**
1922 * 防止重复发送,比较上次发送数据
2023 */
21- private String data = "" ;
24+ private Map < String , Integer > data = new HashMap <>() ;
2225 @ Override
2326 public void process (Page page ) {
2427 String url = page .getHtml ().xpath ("/html/body/div[1]/div[1]/div[3]/div[2]/div[1]/a" ).$ ("a" ,"href" ).toString ();
@@ -33,12 +36,14 @@ public void process(Page page) {
3336 page .putField ("flag" ,false );
3437 if (StringUtils .isNotBlank (page .getHtml ().xpath ("/html/body/div[1]/div[1]/div[3]/div[2]/div[1]/a" ).$ ("a" ,"href" ).toString ())){
3538 String [] split = url .split ("/" );
36- if (data .equals (split [split .length -1 ])){
39+ //存在不推送
40+ if (data .get (split [split .length -1 ]) != null ){
3741 page .putField ("flag" ,false );
3842 return ;
3943 }
4044 page .putField ("flag" ,true );
41- data = split [split .length -1 ];
45+ //不存在存进去
46+ data .put (split [split .length -1 ],1 );
4247 }
4348
4449 }
Original file line number Diff line number Diff line change 66import org .springframework .beans .factory .annotation .Value ;
77import org .springframework .scheduling .annotation .Scheduled ;
88import org .springframework .stereotype .Component ;
9+ import lombok .extern .java .Log ;
910import us .codecraft .webmagic .Spider ;
1011
1112/**
1415 * @Date 2020-12-11
1516 */
1617@ Component
18+ @ Log
1719public class ZdmTask {
1820
1921 private int i ;
2022 @ Autowired
2123 private ZdmPipeline zdmPipeline ;
22- @ Value ("${uid }" )
23- private String uid ;
24+ @ Value ("${blr.uids }" )
25+ private String [] uids ;
2426
2527 ZdmPageProcessor zdmPageProcessor = new ZdmPageProcessor ();
2628
@@ -29,10 +31,16 @@ public class ZdmTask {
2931 */
3032 @ Scheduled (cron = "${corn}" )
3133 public void execute () {
32- Spider .create (zdmPageProcessor )
33- .addUrl ("https://zhiyou.smzdm.com/member/" +uid +"/baoliao/" )
34- .addPipeline (zdmPipeline )
35- .thread (1 )
36- .run ();
34+ if (uids == null || uids .length <= 0 ){
35+ log .info ("~~~~~~~~~~~~~~~~~~~~~~~~~~没有配置需要监控的博主~~~~~~~~~~~~~~~~~~~~~~~~~~" );
36+ return ;
37+ }
38+ for (String uid : uids ){
39+ Spider .create (zdmPageProcessor )
40+ .addUrl ("https://zhiyou.smzdm.com/member/" +uid +"/baoliao/" )
41+ .addPipeline (zdmPipeline )
42+ .thread (1 )
43+ .run ();
44+ }
3745 }
3846}
Original file line number Diff line number Diff line change @@ -6,15 +6,19 @@ spring:
66 application :
77 name : zdm
88key :
9- # 支持两种配置:pushPlus或者serverJ ,二选一
9+ # 支持两种配置:【pushPlus】或者【serverJ】 ,二选一
1010 # pushPlus参考:http://pushplus.hxtrip.com/,不限制次数,不用github账号
1111 # serverJ参考:http://sc.ftqq.com/3.version ,需要github账号,限制次数
1212 type : pushPlus
1313 # 对应平台的key
14- value : 9b343 ***
14+ value : SCU6811****** ***
1515# 爆料人id:https://zhiyou.smzdm.com/member/9687682701/baoliao/ 参考这个链接
16- uid : 9687682701
16+ blr :
17+ # 多个爆料人id用英文隔开即可
18+ uids : 9687682701,2031093162,3050600933
1719# 频率十秒一次 ,
18- corn : 0/10 * * * * ?
20+ # corn: 0/10 * * * * ?
1921# 三十秒一次
2022# corn: 0/30 * * * * ?
23+ # 一分钟一次
24+ corn : 0/59 * * * * ?
You can’t perform that action at this time.
0 commit comments