forked from rbridomzmr/ShadowSocks-Share
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xxx
committed
Jan 22, 2018
1 parent
837f281
commit 5f2d86b
Showing
6 changed files
with
148 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/example/ShadowSocksShare/service/impl/Free_ssServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.example.ShadowSocksShare.service.impl; | ||
|
||
import com.example.ShadowSocksShare.domain.ShadowSocksDetailsEntity; | ||
import com.example.ShadowSocksShare.service.ShadowSocksCrawlerService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.jsoup.nodes.Document; | ||
import org.jsoup.nodes.Element; | ||
import org.jsoup.select.Elements; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.Date; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* https://free-ss.site/ | ||
*/ | ||
@Slf4j | ||
// @Service | ||
public class Free_ssServiceImpl extends ShadowSocksCrawlerService { | ||
// 目标网站 URL | ||
private static final String TARGET_URL = "https://free-ss.site/ss.json?_={0}"; | ||
|
||
/** | ||
* 网页内容解析 ss 信息 | ||
*/ | ||
@Override | ||
protected Set<ShadowSocksDetailsEntity> parse(Document document) { | ||
log.debug("===================>{}", document.html()); | ||
return null; | ||
} | ||
|
||
/** | ||
* 目标网站 URL | ||
*/ | ||
@Override | ||
protected String getTargetURL() { | ||
return MessageFormat.format(TARGET_URL, System.currentTimeMillis()); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/com/example/ShadowSocksShare/service/impl/SsrBlueCrawlerServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.example.ShadowSocksShare.service.impl; | ||
|
||
import com.example.ShadowSocksShare.domain.ShadowSocksDetailsEntity; | ||
import com.example.ShadowSocksShare.service.ShadowSocksCrawlerService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.jsoup.nodes.Document; | ||
import org.jsoup.select.Elements; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Date; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* https://free-ss.site/ | ||
*/ | ||
@Slf4j | ||
@Service | ||
public class SsrBlueCrawlerServiceImpl extends ShadowSocksCrawlerService { | ||
// 目标网站 URL | ||
private static final String TARGET_URL = "http://www.ssr.blue/"; | ||
|
||
/** | ||
* 网页内容解析 ss 信息 | ||
*/ | ||
@Override | ||
protected Set<ShadowSocksDetailsEntity> parse(Document document) { | ||
Elements ssList = document.select("a.btn-info"); | ||
|
||
Set<ShadowSocksDetailsEntity> set = new HashSet(ssList.size()); | ||
for (int i = 0; i < ssList.size(); i++) { | ||
try { | ||
String ssrLink = ssList.get(i).attributes().get("href"); | ||
ShadowSocksDetailsEntity ss = parseLink(ssrLink); | ||
ss.setValid(false); | ||
ss.setValidTime(new Date()); | ||
ss.setTitle(document.title()); | ||
ss.setRemarks(TARGET_URL); | ||
ss.setGroup("ShadowSocks-Share"); | ||
|
||
// 测试网络 | ||
if (isReachable(ss)) | ||
ss.setValid(true); | ||
|
||
// 无论是否可用都入库 | ||
set.add(ss); | ||
|
||
log.debug("*************** 第 {} 条 ***************{}{}", i + 1, System.lineSeparator(), ss); | ||
// log.debug("{}", ss.getLink()); | ||
|
||
} catch (Exception e) { | ||
log.error(e.getMessage(), e); | ||
} | ||
} | ||
return set; | ||
} | ||
|
||
/** | ||
* 目标网站 URL | ||
*/ | ||
@Override | ||
protected String getTargetURL() { | ||
return TARGET_URL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters