Skip to content

Instantly share code, notes, and snippets.

@BryanYang
Created September 29, 2018 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BryanYang/bf5bcb1b64171e47f52f61729f4d7f4f to your computer and use it in GitHub Desktop.
Save BryanYang/bf5bcb1b64171e47f52f61729f4d7f4f to your computer and use it in GitHub Desktop.
// 快递地址从百度获取。(百度首页输入快递,查看请求url)
let url = "https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?appid=4001&com=zhongtong&nu=541247425507&vcode=&token=&_=1538102135046"
let req = new Request(url)
let json = await req.loadJSON()
let items = json.data.info.context
let table = new UITable()
for (item of items) {
let row = new UITableRow()
let time = item.time
let title = decode(item.desc)
let imageCell = row.addText(new Date(Number(time+"000")).toLocaleString())
let titleCell = row.addText("", title)
imageCell.widthWeight = 50
titleCell.widthWeight = 80
row.height = 120
row.cellSpacing = 10
table.addRow(row)
}
QuickLook.present(table)
function decode(str) {a
let regex = /&#(\d+);/g
return str.replace(regex, (match, dec) => {
return String.fromCharCode(dec)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment