Skip to content

Commit

Permalink
支持 freessr
Browse files Browse the repository at this point in the history
Signed-off-by: xxx <x@x.x>
  • Loading branch information
xxx committed Jan 8, 2018
1 parent 7af28fb commit 3e9ed19
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ https://global.ishadowx.net/ | 3 小时
https://doub.io/sszhfx/ | 6 小时
https://freess.cx/ | 12 小时
https://en.ss8.fun/ | 4 小时
https://freessr.win/ | 6 小时


#### TO DO

1. 计划支持下列站点:
1. https://freessr.win/
1. https://plus.google.com/communities/104092405342699579599
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.Set;

/**
* doub 爬虫
* doub
* https://doub.io
*/
@Slf4j
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
* 免费shadowsocks账号
* https://freessr.win/
*/
@Slf4j
@Service
public class FreeSSRCrawlerServiceImpl extends ShadowSocksCrawlerService {
// 目标网站 URL
private static final String TARGET_URL = "https://freessr.win/";

/**
* 网页内容解析 ss 信息
*/
@Override
protected Set<ShadowSocksDetailsEntity> parse(Document document) {
Elements ssList = document.select("div.text-center");

Set<ShadowSocksDetailsEntity> set = new HashSet(ssList.size());
for (int i = 0; i < ssList.size(); i++) {
try {
Element element = ssList.get(i);
// 取 h4 信息,为 ss 信息
Elements ssHtml = element.select("h4");

if (ssHtml.size() >= 5) {
// server
String server = StringUtils.remove(ssHtml.get(0).text(), "服务器地址:");
Assert.hasLength(server, "server 不能为空");

int server_port = NumberUtils.toInt(StringUtils.remove(ssHtml.get(1).text(), "端口:"));
// Assert.isNull(port, "port 不能为空");


String password = StringUtils.remove(ssHtml.get(2).text(), "密码:");
Assert.hasLength(password, "password 不能为空");

String method = StringUtils.remove(ssHtml.get(3).text(), "加密方式:");
Assert.hasLength(method, "method 不能为空");

// 账号状态
String status = ssHtml.get(4).text();
if (status.contains("正常")) {
ShadowSocksDetailsEntity ss = new ShadowSocksDetailsEntity(server, server_port, password, method, SS_PROTOCOL, SS_OBFS);
ss.setValid(false);
ss.setValidTime(new Date());
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Set;

/**
* iShadow 爬虫
* iShadow
* https://global.ishadowx.net/
*/
@Slf4j
Expand All @@ -42,9 +42,9 @@ protected Set<ShadowSocksDetailsEntity> parse(Document document) {
// log.debug(ssHtml.html());
// 如果 得到 大于 5 个(address、port、password、method、agreement、obscure),分别取相应信息
if (ssHtml.size() >= 5) {
// IP Address
// server
String server = ssHtml.get(0).select("span[id]").first().html();
Assert.hasLength(server, "address 不能为空");
Assert.hasLength(server, "server 不能为空");

int server_port = NumberUtils.toInt(ssHtml.get(1).select("span[id]").first().html());
// Assert.isNull(port, "port 不能为空");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class ShadowSocksTasks {
@Autowired
@Qualifier("ss8ServiceImpl")
private ShadowSocksCrawlerService ss8ServiceImpl; // https://en.ss8.fun/
@Autowired
@Qualifier("freeSSRCrawlerServiceImpl")
private ShadowSocksCrawlerService freeSSRCrawlerServiceImpl; // https://global.ishadowx.net/

@Scheduled(cron = "0 10 */3 * * ?")
public void iShadowCrawler() {
Expand All @@ -53,6 +56,11 @@ public void ss8Crawler() {
shadowSocksSerivce.crawlerAndSave(ss8ServiceImpl);
}

@Scheduled(cron = "0 10 */6 * * ?")
public void freeSSRCrawler() {
shadowSocksSerivce.crawlerAndSave(freeSSRCrawlerServiceImpl);
}

/**
* SS 有效性检查,每 1 小时
*/
Expand Down

0 comments on commit 3e9ed19

Please sign in to comment.