我想出了如何打开网页,但我想向谷歌提交表单,然后获取 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 中工作,我们也可以解决。就这么说吧。
关于javascript - 如何使用适用于 mac yosemite 的 javascript automator (JAX) 获取网页的原始 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27457204/