-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
120 lines (99 loc) · 3.23 KB
/
api.js
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
114
115
116
117
118
119
120
Qt.include("tripledes.js")
Qt.include("mode-ecb-min.js")
Qt.include("pad-nopadding-min.js")
Qt.include("base64.js")
var key = "p#a@w^s(";
function getApiBase(){
return "https://api.ithome.com/"
}
function getDynBase(){
return "https://dyn.ithome.com/"
}
function newslist(){
return getApiBase() + "json/newslist/news?r=0";
}
function getRelatedUrl(newsid){
return getApiBase() + "json/tags/0"+ newsid.toString().slice(0,3) +"/"+newsid.toString()+".json"
}
function loadMore(newsid){
var prevNewsid = getLoadMoreId(newsid);
console.log("crypted id:"+prevNewsid)
return getApiBase() + "xml/newslist/news_"+ prevNewsid +".xml"
}
function newsdetail(newsid){
return getApiBase() + "xml/newscontent/"+ newsid.toString().slice(0,3) +"/"+newsid.toString().slice(3,6)+".xml"
}
function getComments(newsid_des){
return getDynBase() + "json/commentlist/350/"+ newsid_des +".json"
}
function getHotCommentlist(newsid_des){
return getDynBase() + "json/hotcommentlist/350/" + newsid_des +".json"
}
function getCommentDetail(newsid_des){
return getDynBase() + "json/commentcontent/"+ newsid_des + ".json"
}
function getSlide(){
return getApiBase() + "xml/slide/slide.xml";
}
function encryptByDES(message, key) {
var keyHex = CryptoJS.enc.Utf8.parse(key);
var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
iv: keyHex,
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.NoPadding
});
return encrypted.toString();
}
function getLoadMoreId(newsid) {
var index = 0;
var i = newsid.toString().length;
if (i < 8) {
i = 8 - i;
} else {
i %= 8;
i = i != 0 ? 8 - i : 0;
}
while (index < i) {
newsid = newsid.toString() + "\u0000";
index++;
}
var encryptd = encryptByDES(newsid, key);
return fmtBytes(str2UTF8(decode64(encryptd)));
}
function fmtBytes(arg5) {
var v1 = "";
for (var v0 = 0; v0 < arg5.length; ++v0) {
var v2 = (arg5[v0] & 255).toString(16);
if (v2.length == 1) {
v1 = v1 + "0" + v2;
} else {
v1 = v1 + v2;
}
}
return v1;
}
function str2UTF8(str){
var bytes = new Array();
var len,c;
len = str.length;
for(var i = 0; i < len; i++){
c = str.charCodeAt(i);
var s = parseInt(c).toString(2);
bytes.push(c & 0xFF);
}
return bytes;
}
/*
新闻列表 https://api.ithome.com/xml/newslist/news.xml
请求更多 https://api.ithome.com/xml/newslist/news_05bffc036ce4305d.xml
文章详情 https://api.ithome.com/xml/newscontent/350/412.xml
相关文章 https://api.ithome.com/json/tags/0350/350362.json
最热评论 https://dyn.ithome.com/json/hotcommentlist/350/87a8e5b144d81938.json
评论列表 https://dyn.ithome.com/json/commentlist/350/87a8e5b144d81938.json
评论详情 https://dyn.ithome.com/json/commentcontent/d739ee8f2ceb0a27.json
轮播新闻 https://api.ithome.com/xml/slide/slide.xml
圈子列表 https://apiquan.ithome.com/api/post?categoryid=0&type=0&orderTime=&visistCount&pageLength
圈子详情 https://apiquan.ithome.com/api/post/236076
圈子评论 https://apiquan.ithome.com/api/reply?postid=236076&replyidlessthan=3241294
评论总数 https://dyn.ithome.com/api/comment/count?newsid=376761
*/