Last active
September 9, 2023 07:52
-
-
Save gnehs/0eff47dea5534b4420a9e83b61d64e6c to your computer and use it in GitHub Desktop.
取得適用於 Master Card 西瓜卡活動的信用卡
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const headers = { | |
accept: "application/json, text/plain, */*", | |
"content-type": "application/json", | |
}; | |
async function getBankList() { | |
let result = await fetch( | |
"https://specials.priceless.com/website/api/v1/issuer", | |
{ | |
headers, | |
referrerPolicy: "origin-when-cross-origin", | |
body: '{"countryCode":"TW","language":"ZH"}', | |
method: "POST", | |
mode: "cors", | |
credentials: "include", | |
} | |
); | |
result = await result.json(); | |
return result; | |
} | |
async function getBankCardList(issuerCode) { | |
let result = await fetch( | |
"https://specials.priceless.com/website/api/v1/issuer-products", | |
{ | |
headers, | |
referrerPolicy: "origin-when-cross-origin", | |
body: JSON.stringify({ issuerCode }), | |
method: "POST", | |
mode: "cors", | |
credentials: "include", | |
} | |
); | |
result = await result.json(); | |
return result; | |
} | |
async function isOfferAvailable(issuerCode, masterCardCode) { | |
let result = await fetch( | |
"https://specials.priceless.com/website/api/v1/search", | |
{ | |
headers, | |
referrerPolicy: "origin-when-cross-origin", | |
body: JSON.stringify({ | |
offerId: "202303130008", | |
issuerCode: issuerCode, | |
masterCardCode: masterCardCode, | |
language: "ZH", | |
sourceMarketCountry: "TW", | |
offset: 0, | |
sort: [ | |
{ | |
properties: "createTime", | |
sort: "lastest", | |
}, | |
], | |
}), | |
method: "POST", | |
mode: "cors", | |
credentials: "include", | |
} | |
); | |
result = await result.json(); | |
return result.count; | |
} | |
async function main() { | |
let bankList = await getBankList(); | |
for (let item of bankList.data) { | |
let { issuerCode, issuerName } = item; | |
let bankCardList = await getBankCardList(issuerCode); | |
for (let card of bankCardList.data) { | |
let { mastercardProductCode, mastercardProductName } = card; | |
let isAvailable = await isOfferAvailable( | |
issuerCode, | |
mastercardProductCode | |
); | |
if (isAvailable) { | |
console.log(`${issuerName} ${mastercardProductName}`); | |
} | |
} | |
} | |
console.log("done"); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment