CrawlStrategy.java
2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package cn.fw.freya.service.crawl;
import cn.fw.freya.enums.AccountTypeEnum;
import cn.fw.freya.model.data.pool.LivePool;
import cn.fw.freya.model.data.pool.VideoPool;
import cn.fw.freya.model.dto.rpc.ReportAccountDto;
import cn.fw.freya.utils.http.InitUserAgent;
import java.io.IOException;
import java.util.List;
/**
* @author null
* @date 2021-11-12 11:28
* @description
*/
public interface CrawlStrategy {
/**
* 账户类型(1:快手, 2:抖音, 3:懂车帝, 4:Bilibili)
*
* @return
*/
AccountTypeEnum getType();
/**
* 登陆准备
*
* @param accountNo 账户号
* @return
*/
String preLogin(String accountNo);
/**
* 登陆
*
* @param accountNo 账户号
* @return
*/
boolean doLogin(String accountNo);
/**
* 获取 UserAgent
*
* @param accountNo 账户号
* @return
*/
default String getUserAgent(String accountNo) {
return InitUserAgent.getOne();
}
/**
* 随机等待时长
*
* @param seconds
*/
default void waitFor(int seconds) {
try {
Thread.sleep(seconds * 1000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
/**
* 随机等待时长
*
* @param seconds
*/
default void waitFor(double seconds) {
try {
Thread.sleep((long) (seconds * 1000));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
/**
* 退出浏览器
*
* @param accountNo 账户号
* @return
*/
default boolean exitBrowser(String accountNo) {
return true;
}
/**
* 获取所有视频信息
*
* @param accountNo 账户号
* @return
* @throws IOException
*/
List<VideoPool> getAllVideoMsg(String accountNo) throws IOException;
/**
* 获取昨日所有直播信息
*
* @param accountNo 账户号
* @return
* @throws IOException
*/
List<LivePool> getYesterdayLiveMsg(String accountNo) throws IOException;
/**
* 更新账户信息
*
* @param accountNo 账户号
* @return
* @throws IOException
*/
ReportAccountDto updateAccountMsg(String accountNo) throws IOException;
}