gpt4 book ai didi

google-chrome - 如何使用 Chrome Headless 模式延迟捕获 DOM

转载 作者:行者123 更新时间:2023-12-03 17:03:38 26 4
gpt4 key购买 nike

我在 Windows 10 上的 Chrome 70 中使用以下命令行:

Chrome --headless --enable-logging --dump-dom http://localhost/test.html

该页面包含以下内容:

<!DOCTYPE html>
<html>
<head>
<script>
setTimeout(function () { document.write("This is a test"); }, 10);
</script>
</head>
<body>
Content to replace.
</body>
</html>

请注意,我有脚本模拟异步过程来查询数据。将超时设置为 10 毫秒,Chrome 命令行的页面输出为:
<html><head></head><body>This is a test</body></head></html>

当我将超时增加到 50 或更多时,输出是原始页面。

我如何告诉 Chrome 等待异步进程的完成以及我如何告诉它何时完成?

最佳答案

您可以使用 --virtual-time-budget允许您指定愿意等待的时间(以毫秒为单位)的参数。

chrome --headless --enable-logging --dump-dom --virtual-time-budget=10000 http://localhost/test.html

关于google-chrome - 如何使用 Chrome Headless 模式延迟捕获 DOM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53526799/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com