- Replace `src/Cookie.ts` with direct `Browser` and `Page` management in `Bandai` class. - Implement lazy initialization for the browser instance to avoid redundant startup costs. - Update `loginBandai` to accept an existing `browserAndPage` context rather than creating a new one. - Improve login status verification by checking for the login button ID instead of generic text. - Add `getCartList` to parse cart HTML using `cheerio` and `set-cookie-parser`. - Add `order` and `open` methods to navigate and interact with specific URLs via Puppeteer. - Update `puppeteer-utils` to save cookies automatically on page load. - Remove legacy `src/Cookie.ts` and `src/Cookie.ts` usage. - Bump `set-cookie-parser` dependency to `^3.1.0`.
18 lines
579 B
TypeScript
18 lines
579 B
TypeScript
import Bandai from "../src/Bandai";
|
|
|
|
async function main() {
|
|
const email = 'allin-603@outlook.com';
|
|
const password = '123456789qw';
|
|
const account = new Bandai(email, password);
|
|
const accountInfo = await account.login();
|
|
console.debug('Account', accountInfo);
|
|
const url = 'https://p-bandai.jp/item/item-1000245579/?spec=pc21&cref=500894283&click_recom=1';
|
|
await account.order(url);
|
|
const cartList = await account.getCartList();
|
|
console.debug('Cart', cartList);
|
|
await account.open('https://p-bandai.jp/cart');
|
|
}
|
|
|
|
main().then(() => {
|
|
console.debug('Done');
|
|
}); |