Skip to content

Instantly share code, notes, and snippets.

@libook
Last active July 19, 2017 05:30
Show Gist options
  • Save libook/4f619fd926b5168c2beecfd3b921dc0f to your computer and use it in GitHub Desktop.
Save libook/4f619fd926b5168c2beecfd3b921dc0f to your computer and use it in GitHub Desktop.
爬自己阿里云账号中的所有工单记录,再进行分析。
function getQuestionListUrl(index) {
return 'https://workorder.console.aliyun.com/json/page/query_index.json?__preventCache=' + (new Date()).getTime() + '&currentPage=' + index + '&page=' + index + '&pageSize=100&status=';
}
function getQuestions() {
let questions = [];
for (let p = 1; p <= 4; p++) {
let url = getQuestionListUrl(p);
$.ajax({
url,
success: (result) => {
questions = questions.concat(result.data);
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
contentType: "application/json",
async: false
});
}
return questions;
}
function getDetailUrl(questionId) {
return 'https://workorder.console.aliyun.com/json/page/detail.json?__preventCache=' + (new Date()).getTime() + '&questionId=' + questionId;
}
function getAdminNotes() {
let questions = getQuestions();
let notes = [];
questions.forEach((question) => {
let url = getDetailUrl(question.vid);
$.ajax({
url,
success: (result) => {
notes = notes.concat(result.data.questionNoteList.filter((comment) => comment.admin));
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
contentType: "application/json",
async: false
});
});
return notes;
}
function filterProblem() {
let notes = getAdminNotes();
return notes.filter((note) => (/bug|紧急|修复|上线/i).test(note.content));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment