Files
claw/tests/fixtures/generated_scene/paginated_enrichment/index.html

56 lines
1.3 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Paginated Enrichment Fixture</title>
</head>
<body>
<script>
const sourceUrl = "http://yx.gs.sgcc.com.cn";
async function getUserList(page, pageSize) {
return $.ajax({
url: "http://yx.gs.sgcc.com.cn/marketing/userList",
type: "POST",
contentType: "application/json",
data: JSON.stringify({ page, pageSize })
});
}
async function getUserCharges(custNo) {
return $.ajax({
url: "http://yx.gs.sgcc.com.cn/marketing/userCharges",
type: "POST",
contentType: "application/json",
data: JSON.stringify({ custNo })
});
}
async function executeTask() {
const pageSize = 100;
let page = 1;
const rows = [];
while (page < 10) {
const response = await getUserList(page, pageSize);
const list = response.rows || [];
if (!list.length) break;
for (const item of list) {
const chargeInfo = await getUserCharges(item.custNo);
const row = { ...item, charge: chargeInfo.charge };
if (row.charge !== 0) {
rows.push(row);
}
}
page += 1;
}
exportExcel(rows);
return rows;
}
function exportExcel(rows) {
return rows.length;
}
</script>
</body>
</html>