简体   繁体   中英

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. 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; just use the command line to get the text directly, using something like 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. Just say so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM