``` await page.goto('
https://landchg.tcd.gov.tw/Module/RWD/Web/pub_exhibit.aspx')
// this page has two dropdown
// one is year,
// the other is county
// we need to select each year and each cities
// save save the target html source down
// first save all available year and cities
// select[name="ProjectYear"]
// select[name="City"]
const yearOptions = await page.$$('select[name="ProjectYear"] option')
const cityOptions = await page.$$('select[name="City"] option')
const years = await Promise.all(yearOptions.map(async (option) => {
return await option.evaluate((node) => node.getAttribute('value'))
}))
const cities = await Promise.all(cityOptions.map(async (option) => {
return await option.evaluate((node) => node.getAttribute('value'))
})
// then loop through each year and cities
// and save the html source down
for (const year of years) {
for (const city of cities) {
await page.selectOption('select[name="ProjectYear"]', year)
await page.selectOption('select[name="City"]', city)
await page.waitForLoadState('networkidle')
await page.waitForTimeout(5000)
await page.innerHTML('html', { timeout: 0 }).then((html) => {
fs.writeFileSync(path.join(downloadDir, `${year}-${city}.html`), html)
})
}
}```