[英]Get a javascript variable from a web page without interaction/heedlessly
Good afternoon, We're looking to get a javascript variable from a webpage, that we are usually able to retrieve typing app
in the Chrome DevTools.下午好,我们希望从网页中获取 javascript 变量,我们通常能够在 Chrome DevTools 中检索打字
app
。
However, we're looking to realize this headlessly as it has to be performed on numerous apps.但是,我们希望无头地实现这一点,因为它必须在众多应用程序上执行。
Our ideas:我们的想法:
Using a Puppeteer instance to go on the page, type the command and return the variable, which works, but it's very ressource consuming.在页面上使用 Puppeteer 实例到 go,键入命令并返回变量,这有效,但非常耗资源。
Using a GET/POST request to the page trying to inject the JS command, but we didn't succeed.对页面使用 GET/POST 请求试图注入 JS 命令,但我们没有成功。
We're then wondering if there will be an easier solution, as a special API that could extract the variable?然后我们想知道是否会有更简单的解决方案,例如可以提取变量的特殊 API? The goal would be to automate this process with no human interaction.
目标是在没有人工交互的情况下自动执行此过程。
Thanks for your help!谢谢你的帮助!
You can embed Chrome into your application and instrument it.您可以将 Chrome 嵌入到您的应用程序中并对其进行检测。 It will be headless.
它将是无头的。
We've used this approach in the past to copy content from PowerPoint Online.我们过去曾使用这种方法从 PowerPoint Online 复制内容。
We were using .NET to do this and therefore used CEFSharp.我们使用 .NET 来执行此操作,因此使用了 CEFSharp。
Your question is not so much about a JS API (since the webpage is not yours to edit, you can only request it) as it is about webcrawling / browser automation.您的问题与其说是关于 JS API(因为该网页不是您可以编辑的,您只能请求它),不如说是关于网络爬虫/浏览器自动化。
You have to add details to get a definitive answer, but I see two scenarios:您必须添加详细信息才能获得明确的答案,但我看到两种情况:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.