如何使用 JavaScript automator (JAX) for Mac yosemite 获取网页的原始 HTM

how can I get raw html for a web page using javascript automator (JAX) for mac yosemite?

本文关键字:获取 yosemite 网页 HTM 原始 Mac for JavaScript 何使用 automator JAX      更新时间:2023-09-26

我想出了如何打开网页,但我想向谷歌提交一个表单,然后得到html结果。 我该怎么做?我想获取这些页面结果,以便我可以自己解析数据。

chrome = Application("Google Chrome");
win = chrome.Window().make();
chrome.windows[0].tabs[0].url = "https://google.com";
// submit form button to search for "test"
//generated_html_from_chrome = ??

如果你真的想要谷歌搜索的原始html,那么根本不需要使用Chrome;只需使用命令行直接获取文本,使用类似curl的东西。

var mysearch = "test"
app = Application.currentApplication()
app.includeStandardAdditions = true
app.doShellScript('curl -D - https://www.google.com/#q=' + mysearch)

如果您确实需要在Chrome中工作,我们也可以解决这个问题。就这么说吧。