使用 PuppeteerSharp,我正在尝试performance.timeOrigin
使用下面的 C# 代码获取值:
JToken performanceTimeOriginString = await _page.EvaluateFunctionAsync("JSON.stringify(performance.timeOrigin);").ConfigureAwait(false);
但是,当我运行上面的 PuppeteerSharp 代码时,我得到以下异常:
System.AggregateException: One or more errors occurred. (Evaluation failed: SyntaxError: Unexpected token ';') ---> PuppeteerSharp.EvaluationFailedException: Evaluation failed: SyntaxError: Unexpected token ';'
at PuppeteerSharp.ExecutionContext.ExecuteEvaluationAsync(String method, Object args)
at PuppeteerSharp.ExecutionContext.RemoteObjectTaskToObject[T](Task`1 remote)
at PuppeteerSharp.DOMWorld.EvaluateFunctionAsync[T](String script, Object[] args)
--- End of inner exception stack trace ---
它告诉我删除分号(很奇怪),所以我尝试了,但随后出现以下异常。
System.AggregateException: One or more errors occurred. (Protocol error (Runtime.callFunctionOn): Given expression does not evaluate to a function) ---> PuppeteerSharp.EvaluationFailedException: Protocol error (Runtime.callFunctionOn): Given expression does not evaluate to a function ---> PuppeteerSharp.MessageException: Protocol error (Runtime.callFunctionOn): Given expression does not evaluate to a function
at PuppeteerSharp.CDPSession.SendAsync(String method, Object args, Boolean waitForCallback)
at PuppeteerSharp.CDPSession.SendAsync[T](String method, Object args)
at PuppeteerSharp.ExecutionContext.ExecuteEvaluationAsync(String method, Object args)
--- End of inner exception stack trace ---
如何使用 PuppeteerSharp 获取 的值performance.timeOrigin
?