Note that the type definitions are incorrect.
+ + ```typescript + import { parse as parseHtml } from "node-html-parser"; + + export type ShopItem = { + name: string; + description: string; + fulfillmentDescription: string; + id: string; + imageUrl: string; + maxOrderQuantity: number; + price: number; + }; + + export default function parseArcadeShopHtml(html: string): ShopItem[] { + const document = parseHtml(html); + const inner = document.getElementById("\_\_NEXT_DATA\_\_")?.text!; + + const items = JSON.parse(inner).props.pageProps.availableItems.map((item: any) => { + return { + name: item\["Name"], + description: item\["Description"], + fulfillmentDescription: item\["Fulfillment Description"], + id: item.id, + imageUrl: item\["Image URL"], + maxOrderQuantity: item\["Max Order Quantity"], + price: item\["Cost Hours"], + }; + }); + + return items; +``` +Note that the type definitions are incorrect.
- - ```typescript - import { parse as parseHtml } from "node-html-parser"; - - export type ShopItem = { - name: string; - description: string; - fulfillmentDescription: string; - id: string; - imageUrl: string; - maxOrderQuantity: number; - price: number; - }; - - export default function parseArcadeShopHtml(html: string): ShopItem[] { - const document = parseHtml(html); - const inner = document.getElementById("\_\_NEXT_DATA\_\_")?.text!; - - const items = JSON.parse(inner).props.pageProps.availableItems.map((item: any) => { - return { - name: item\["Name"], - description: item\["Description"], - fulfillmentDescription: item\["Fulfillment Description"], - id: item.id, - imageUrl: item\["Image URL"], - maxOrderQuantity: item\["Max Order Quantity"], - price: item\["Cost Hours"], - }; - }); - - return items; -``` -