use*_*629 23 javascript node.js visual-studio-code puppeteer
我开始使用 pupeteer 和 node 并在 win 10 中使用 vscode。我正在尝试登录一个站点并抓取一张表。到目前为止,我有:
(async () => {
const browser = await puppeteer.launch({
headless: false,
});
var page = await browser.newPage();
await page.goto('thesite.com/login/');
await page.click(USERNAME_SELECTOR);
await page.keyboard.type(CREDS.username);
await page.click(PASSWORD_SELECTOR);
await page.keyboard.type(CREDS.password);
await page.click(BUTTON_SELECTOR);
await page.waitForNavigation();
const TABLE_ROW_SELECTOR = '.gv-container.gv-container-133 > table > tbody';
await page.waitForSelector(TABLE_ROW_SELECTOR);
await page.waitForSelector(TABLE_ROW_SELECTOR);
await page.screenshot({ path: 'example.png' });
const data = await page.evaluate(SELECTOR => document.querySelectorAll(SELECTOR), TABLE_ROW_SELECTOR);
await browser.close();
})();
Run Code Online (Sandbox Code Playgroud)
这主要是有效的。但是在我的控制台中,我看到了一个对象列表,但据我所知,没有任何值。这是最重要的对象:
0:Object {}
__proto__:Object {constructor: , __defineGetter__: , __defineSetter__: , …}
__defineGetter__:function __defineGetter__() { … }
__defineSetter__:function __defineSetter__() { … }
__lookupGetter__:function __lookupGetter__() { … }
__lookupSetter__:function __lookupSetter__() { … }
constructor:function Object() { … }
hasOwnProperty:function hasOwnProperty() { … }
No debug adapter, can not send 'variables'
isPrototypeOf:function isPrototypeOf() { … }
No debug adapter, can not send 'variables'
Run Code Online (Sandbox Code Playgroud)
“没有调试适配器,不能发送‘变量’”是什么意思?
编辑:
我更新到最新的 vscode 并检查所有扩展是否已更新。现在当我运行 LAUNCH PROGRAM
E:\nodejs\node.exe --inspect-brk=27108 index.js
Debugger listening on ws://127.0.0.1:27108/e5928c71-370c- 4111-9ec3-77bb2cd85075
For help, see: https://nodejs.org/en/docs/inspector
(node:12844) ExperimentalWarning: The fs.promises API is experimental
warning.js:18
Array(25) [ElementHandle, ElementHandle, ElementHandle, ElementHandle, ElementHandle, ElementHandle, ElementHandle, ElementHandle, …]
index.js:64
length:25
__proto__:Array(0) [, …]
concat:function concat() { … }
[[Scopes]]:Scopes[0]
arguments:TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
Run Code Online (Sandbox Code Playgroud)
知道这是什么意思吗?
Nic*_*ick 34
我在尝试使用integratedConsole而不是integratedTerminal或externalTerminal作为我的 Node 配置的一部分时遇到了这个问题launch.json:
将其设置回:
"console": "integratedTerminal"
Run Code Online (Sandbox Code Playgroud)
修复。只花了一个小时就搞清楚了。有关更多信息,请参阅文档。
小智 22
你也可以试试:
“输出捕获”:“标准”
在你的launch.json
Tia*_*nga 11
发生这种情况的原因是调试器在代码执行结束后停止。然后没有更多的调试适配器可用于发送变量。我所做的是在代码执行的底部添加一个额外的行,并在其上设置一个断点。它不漂亮,但它有效。
| 归档时间: |
|
| 查看次数: |
32569 次 |
| 最近记录: |