简体   繁体   English

如何使用适用于Mac优胜美地的javascript automator(JAX)获取网页的原始html?

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

I figured out how to open a web page, but I want to submit a form to google and then get the html results. 我想出了如何打开网页,但是我想向Google提交表单,然后获取html结果。 how can I do this? 我怎样才能做到这一点? I want to take those page results so I can parse the data myself. 我想获取这些页面结果,以便自己解析数据。

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 = ??

If you are genuinely wanting just the raw html of google searches, then no need to use Chrome at all; 如果您真的只想要google搜索的原始html,则根本不需要使用Chrome; just use the command line to get the text directly, using something like curl. 只需使用命令行即​​可直接获取文本,例如使用curl。

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

If you do need to be working in Chrome, we can figure that out too. 如果您确实需要在Chrome中工作,我们也可以解决。 Just say so. 只是这样说。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将任意网页的原始html下载到Javascript字符串中? - How can I download the raw html of an arbitrary web page into a Javascript string? 如何使用 javascript 将原始 html 嵌入页面 - How to embed raw html into page using javascript 如何使用 Javascript 在我的 HTML 页面中获取输出 - How can i get output in my HTML page using Javascript 我如何使用JavaScript将jenkins数据获取到HTML页面 - How can I get jenkins data to an HTML page using javascript 如何将使用javascript的网页转换为纯HTML? - How can I convert web page with javascript to plain html? 如何遍历 XML 文件并使用 JavaScript 在 HTML 网页中显示数据? - How can I iterate over an XML file and display the data in a HTML web page using JavaScript? Web 抓取:下一页在 Javascript 中呈现,我如何使用 Scrapy 获得它 - Web Scraping: Next page is rendered in Javascript, how can I get it using Scrapy 如何使用HtmlUnit从JavaScript html页面获取结果? - How can I get the result from the JavaScript html page using HtmlUnit? 我如何从具有javascript功能的页面获取html? - How can i get html from a page that has javascript function? 我如何在 html 页面中获得带有 Javascript 的简单日历 window - How can i get an simple calendar window with Javascript in an html page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM