javascript - 用于获取网页输出的 powershell 脚本,其中包括用于表单的 javascripts
问题描述
我正在尝试编写一个 powershell 脚本来读取一个使用 javascript 的网页并获取输出。网页源代码如下所示,但浏览器中的页面本身具有由于 javascripts 的形式。我需要通过 powershell 获取表单,但到目前为止还没有成功,因为 Invoke-WebRequest 或 Invoke-RestMethod 只是获取了引用 js 的内容。
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><meta name=robots content=noindex><link rel=icon href=/websellingbooking/favicon.ico><title>Loading</title><link rel=stylesheet href=/websellingbooking/css/custom.css nonce="nonce-GzB2v2o2sBKmQkE5xM+0cPpjQ+rO8KyK/kI1DdxAQUY=" type=text/css><link href=/websellingbooking/css/app.4975c048.css rel=preload as=style><link href=/websellingbooking/css/bulks-sellerss.67fb10ba.css rel=preload as=style><link href=/websellingbooking/js/app.0c50239a.js rel=preload as=script><link href=/websellingbooking/js/bulks-sellerss.08a611c4.js rel=preload as=script><link href=/websellingbooking/css/bulks-sellerss.67fb10ba.css rel=stylesheet><link href=/websellingbooking/css/app.4975c048.css rel=stylesheet></head><body><div id=app></div><script src=/websellingbooking/js/bulks-sellerss.08a611c4.js></script><script src=/websellingbooking/js/app.0c50239a.js></script></body></html>
解决方案
A) There is no HTML form in the source. If you have control over the websites, it might be an option to write complete HTML pages/templates including the form. That way, all elements are downloadable.
B) The Chromium browser can be used in a headless way, which means without a graphical user interface. Thus one can request a website on a server-environment and get a fully rendered snapshot of the page, as it was loaded in Chromium. See also: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
推荐阅读
- javascript - 我如何使用 jest 来确保我只使用两个参数?
- google-analytics - GTM & Google Analytics 4 // 购买多个产品的事件
- linux-kernel - 内核模块编译的内核头文件
- reactjs - Material-ui 主题组件库中的自托管字体不起作用
- c# - c#函数接受和处理类型T的对象
- java - 使用 ng-flow 上传多个文件
- c - 递归函数中局部变量的地址减少
- c - 如何以编程方式将代码与 LD 链接
- python - panda groupby ID,并计算相对于坐标中心的半径
- java - Toast 消息保留很长时间