|
|
@@ -22,6 +22,7 @@ import top.lvzhiqiang.exception.BusinessException;
|
|
|
import top.lvzhiqiang.exception.ParameterException;
|
|
|
import top.lvzhiqiang.mapper.*;
|
|
|
import top.lvzhiqiang.service.BgService;
|
|
|
+import top.lvzhiqiang.service.Crawler4JavbusService;
|
|
|
import top.lvzhiqiang.util.DateUtils;
|
|
|
import top.lvzhiqiang.util.JsoupUtil;
|
|
|
import top.lvzhiqiang.util.StringUtils;
|
|
|
@@ -30,6 +31,7 @@ import javax.annotation.Resource;
|
|
|
import java.io.*;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.net.InetSocketAddress;
|
|
|
import java.net.Proxy;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.time.Instant;
|
|
|
@@ -75,12 +77,16 @@ public class BgServiceImpl implements BgService {
|
|
|
private VideoInfoInfantryMapper videoInfoInfantryMapper;
|
|
|
@Resource
|
|
|
private CrawlerLoveFootMapper crawlerLoveFootMapper;
|
|
|
+ @Resource
|
|
|
+ private Crawler4JavbusService crawler4JavbusService;
|
|
|
|
|
|
@Value("${spring.profiles.active}")
|
|
|
private String env;
|
|
|
|
|
|
private String ignoreFileTypeSuffix = "";
|
|
|
|
|
|
+ private Proxy proxy = null;
|
|
|
+
|
|
|
/**
|
|
|
* findDicCode
|
|
|
*
|
|
|
@@ -415,20 +421,39 @@ public class BgServiceImpl implements BgService {
|
|
|
*/
|
|
|
@Async
|
|
|
@Override
|
|
|
- public void jsoupVideoInfo(Integer status) {
|
|
|
+ public void jsoupVideoInfo(Integer status, String website, String url, String identificationCodeP) {
|
|
|
log.warn("jsoupVideoInfo 开始:status={}", status);
|
|
|
|
|
|
// 获取待抓取码列表
|
|
|
- List<String> icodeList = videoInfoMapper.findIcodeByStatus(status);
|
|
|
- if (icodeList.size() == 0) {
|
|
|
- log.warn("status={}的icodeList为空", status);
|
|
|
- return;
|
|
|
+ List<String> icodeList = new ArrayList<>();
|
|
|
+ if (StringUtils.isEmpty(identificationCodeP)) {
|
|
|
+ icodeList = videoInfoMapper.findIcodeByStatus(status);
|
|
|
+ if (icodeList.size() == 0) {
|
|
|
+ log.warn("status={}的icodeList为空", status);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ icodeList.add(identificationCodeP);
|
|
|
}
|
|
|
+
|
|
|
// 获取javbus防屏蔽地址
|
|
|
- List<String> javbusUrlList = videoSitePoolMapper.findUrlByTypeAndDeleteFlag(1, 1);
|
|
|
- if (javbusUrlList.size() == 0) {
|
|
|
- log.warn("javbusUrlList为空");
|
|
|
- return;
|
|
|
+ List<String> javbusUrlList = new ArrayList<>();
|
|
|
+ if (StringUtils.isEmpty(url)) {
|
|
|
+ javbusUrlList = videoSitePoolMapper.findUrlByTypeAndDeleteFlag(1, 1);
|
|
|
+ if (javbusUrlList.size() == 0) {
|
|
|
+ log.warn("javbusUrlList为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ javbusUrlList.add(url);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == proxy) {
|
|
|
+ if ("dev".equals(env)) {
|
|
|
+ proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 1080));
|
|
|
+ } else {
|
|
|
+ proxy = Proxy.NO_PROXY;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 获取图片保存路径
|
|
|
@@ -449,10 +474,12 @@ public class BgServiceImpl implements BgService {
|
|
|
try {
|
|
|
document = Jsoup.connect(javbusUrl.concat("/").concat(identificationCode))
|
|
|
.timeout(50000)
|
|
|
- //.proxy()
|
|
|
- //.data()
|
|
|
- .ignoreContentType(true)
|
|
|
+ .proxy(proxy)
|
|
|
.userAgent(getUserAgent())
|
|
|
+ .followRedirects(true)
|
|
|
+ .ignoreContentType(true)
|
|
|
+ .ignoreHttpErrors(true)
|
|
|
+ .cookies(crawler4JavbusService.getJavbusCookiesMap())
|
|
|
.header("referer", "https://www.javbus.com/".concat(identificationCode))
|
|
|
.get();
|
|
|
|
|
|
@@ -490,7 +517,7 @@ public class BgServiceImpl implements BgService {
|
|
|
public void getMaleCast(VideoInfo videoInfo) {
|
|
|
Document document;
|
|
|
try {
|
|
|
- Map<String,String> headerMap = new HashMap<>();
|
|
|
+ Map<String, String> headerMap = new HashMap<>();
|
|
|
headerMap.put("referer", "avdanyuwiki.com");
|
|
|
|
|
|
document = JsoupUtil.requestDocument("https://avdanyuwiki.com/?s=".concat(videoInfo.getName()), JsoupUtil.HTTP_GET, Proxy.NO_PROXY, null, headerMap, null);
|