// Copyright 2026 Leo Cheng
// SPDX-License-Identifier: Apache-2.0

///|
/// A page in, a table out: the shape of every scraping job.
///
///     moon run examples/scrape
#coverage.skip
fn main raise @moonxml.Refused {
  let page = @html.loads(
    "" +
    "
itemprice
coffee4.50
tea3.00
cocoa5.25
", ) println("item,price") for row in page.css("#prices tbody tr").items { let cells = row.css("td") println("\{cells.first().text()},\{cells.last().text()}") } let mut total = 0.0 for cell in page.css("td:last-child").items { total = total + parse_price(cell.text()) } println("total,\{total}") } ///| fn parse_price(text : String) -> Double { @string.parse_double(text) catch { _ => 0.0 } }