Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/examples/example.org.ts
1028 views
1
import agent from 'secret-agent';
2
3
async function run() {
4
await agent.goto('https://example.org/');
5
await agent.waitForPaintingStable();
6
7
console.log('\n-- PRINTING location.href ---------');
8
console.log(await agent.url);
9
10
const html = await agent.document.documentElement.outerHTML;
11
console.log('-- PRINTING outerHTML ---------------');
12
console.log(html);
13
agent.output.html = html;
14
agent.output.title = await agent.document.title;
15
agent.output.intro = await agent.document.querySelector('p').textContent;
16
17
console.log('-------------------------------------');
18
19
await agent.close();
20
21
console.log('OUTPUT from https://example.org', agent.output);
22
}
23
24
run().catch(error => console.log(error));
25
26