Scriptable Thursday morning

// 📘 Guam White Pages Lookup via Scriptable
// by Ray’s request – GUI + multi-page + JSON/CSV export

let query = await Prompt.text(“Enter a name to search (e.g. camacho)”) let pages = parseInt(await Prompt.text(“How many pages to fetch? (1-5)”), 10)

if (!query || isNaN(pages)) {
return new Alert(“Missing info”).present()
}

let results = []
let baseURL = ‘https://www.guamphonebook.com/whitepages

for (let i = 1; i <= pages; i++) {
let url = `${baseURL}?name=${encodeURIComponent(query)}&page=${i}` let req = new Request(url)
req.headers = { “User-Agent”: “ScriptableBot/1.0” }
let html = await req.loadString()

let matches = […html.matchAll(/listing-name[^>]*>(.*?)<\/.*?listing-phone[^>]*>(.*?))]
for (let match of matches) {
results.push({ name: match[1].trim(), phone: match[2].trim() }) }
}

if (results.length === 0) {
return new Alert(“No results found.”).present()
}

let menu = new UITable()
results.forEach(item => {
let row = new UITableRow()
row.addText(`${item.name}`, item.phone)
menu.addRow(row)
})

QuickLook.present(results, true)
menu.present()

// Optional: Save JSON to Files
let file = FileManager.iCloud().joinPath(FileManager.iCloud().documentsDirectory(), `${query}_guam.json`) await FileManager.iCloud().writeString(file, JSON.stringify(results, null, 2)) console.log(“Saved to: ” + file)

Leave a comment