// ${name: getBazhanList}
// ${title: 读取扒站历史记录}

import console; 
import web.rest.client;

var http = web.rest.client();

console.showLoading("数据读取中ing...")

var getToken = http.api("https://bazhan.me/list", "GET" ,`token\s*content\=\"(.+?)\"`)

http.addHeaders = {
    ["x-csrf-token"] = getToken();
}

var getUrl = http.api("https://bazhan.me/sites", "GET" ,function(ret){
    var ret, lst = ret + '\n', {};
	for k, v in string.gmatch( ret, "\n[\c|\w]?(.*?)\c.\s?(.*?)\c" ) 
		table.push(lst, {site = k; url = v})
	return lst; 
})

var lst = getUrl()
console.dumpJson( lst )
console.printf("总计读取数据:%s 条", #lst )

console.pause(true);

// https://suiang.cn/aardio/code/getBazhanList