Java爬取百度云觀測(cè)對(duì)網(wǎng)站的檢測(cè)數(shù)據(jù),獲取子域名及域名的安全信息
百度云觀測(cè)有對(duì)域名的檢測(cè)還比較全面。下面我們來(lái)抓取下內(nèi)容看看。
Java抓取代碼
直接上代碼,HTTP工具類暫時(shí)不能提供給您,您隨便自己請(qǐng)求就可以了,只要能通,能返回?cái)?shù)據(jù)。
//獲取子域名 & 子域名評(píng)分
public List<DomainCheckInfoDto.SSLDomain> SSLDomains(String surl){
String domain = StringUtils.getHost(surl);
surl = String.format("http://ce.baidu.com/index/getRelatedSites?site_address=%s", StringUtils.strToUrlcode(surl)) ;
List<DomainCheckInfoDto.SSLDomain> domainList = new ArrayList<>();
String res = Http.create(surl).
head("Accept", "application/json, text/javascript, */*; q=0.01")
.head("Accept-Encoding", "gzip, deflate")
.head("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8")
.head("Cache-Control", "no-cache")
.head("Connection", "keep-alive")
.head("Cookie", "您的百度登錄Cookie")
.head("Host", "ce.baidu.com")
.head("Pragma", "no-cache")
.head("Referer", String.format("http://ce.baidu.com/index/guance?start_url=%s", domain))
.head("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36")
.head("X-Requested-With", "XMLHttpRequest")
.timeout(3)
.readTimeout(3)
.get().send().getResponse().getResult();
if(StringUtils.isNotBlank(res) ){
JSONObject json = JSONObject.fromObject(res);
int code = json.optInt("code", 1);
if(0 == code){//成功
JSONArray data = json.optJSONArray("data");
//最多弄10個(gè)域名,有的時(shí)候子域名太多了
for (int i = 0; i < data.size() && i< 10; i++) {
Object datum = data.get(i);
JSONObject target = null;
if(datum instanceof JSONObject){
target = (JSONObject)datum;
}else{
target = JSONObject.fromObject(datum);
}
DomainCheckInfoDto.SSLDomain sslDomain = new DomainCheckInfoDto.SSLDomain(target);
domainList.add(sslDomain);
}
}
}
return domainList;
}然后里面有一個(gè)實(shí)體類:
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class SSLDomain{
//分值
private int score;
//域名
private String domain;
public SSLDomain(JSONObject obj){
this.score = obj.optInt("score", 60);
this.domain = obj.optString("domain", "");
}
}數(shù)據(jù)返回:
{
"attackSSL":{
"name":"攻擊風(fēng)險(xiǎn)",
"score":75,
"scoreDelta":0
},
"cateId":"medial",
"cateName":"影視音樂(lè)",
"cateScore":60,
"domainLastScore":54,
"domainSize":10,
"domsins":[
{
"domain":"air.sojson.com",
"score":84
},
{
"domain":"api.sojson.com",
"score":54
},
{
"domain":"css.sojson.com",
"score":80
},
{
"domain":"fm.sojson.com",
"score":80
},
{
"domain":"icp.sojson.com",
"score":94
},
{
"domain":"js.sojson.com",
"score":65
},
{
"domain":"m.sojson.com",
"score":80
},
{
"domain":"open.sojson.com",
"score":90
},
{
"domain":"sojson.com",
"score":90
},
{
"domain":"t.weather.sojson.com",
"score":80
}
],
"envSSL":{
"name":"網(wǎng)站服務(wù)",
"score":40,
"scoreDelta":0
},
"historySSL":{
"name":"網(wǎng)站歷史安全",
"score":100,
"scoreDelta":0
},
"id":"17bb1d64a239c585",
"rank":0,
"realtimeSSL":{
"name":"網(wǎng)站惡意內(nèi)容",
"score":75,
"scoreDelta":0
},
"synopsis":73,
"updatedTime":"2020-03-31 17:51:27"
}這個(gè)是查詢SOJSON.COM的結(jié)果
版權(quán)所屬:SO JSON在線解析
原文地址:http://suancuo.cn/blog/361.html
轉(zhuǎn)載時(shí)必須以鏈接形式注明原始出處及本聲明。
如果本文對(duì)你有幫助,那么請(qǐng)你贊助我,讓我更有激情的寫(xiě)下去,幫助更多的人。
