Exists such thing as mozrepl for Safari? Looking for an Safari extension (or plugin) what acts as mozrepl, what works like a charm. :)


Exists such thing?


If not, is possible somewhat easily control Safari from external scripts (perl, python, bash)? With control mean:


GET urls (mean http GET method) - Via safari (e.g. the Safari will send the auth, session cookies, referere and so on).
get source of the page (after the Safari renders all ajax calls and such)
POST via Safari (for example using AJAX - but initieted from teh external script)
etc...
in short like: "mozrepl" :)


Seems, here is nothing comparable yet. I didn't delete the question, is someone found such thing - please add an answer.

Ps: i know, how to use curl or like tools, but this isn't helps for e.g. grabbing a content of pages, where Safari managing the session authentication, cookies, referrers , user-agent strings and so on. Everything is rev-engineerable, but it is much easier to use a tool like mozrepl as doing the fullstack rev-engineering for getting scriptable web-sessions...)
If the main idea is scripting Safari, I would try using Automator before trying AppleScript. I'd start by hitting the record button and then:


Open Safari
Navigate to your webpage
GET by saving the webpage source
Allow the page to do whataver AJAX calls you may want it to do

save the webpage source again

Fill out a form, hit submit for your POST

save the webpage source yet again



Or you could try AppleScript with something like this:

tell application "Safari"
    tell window 1
    set current tab to (make new tab with properties {URL:"http://www.example.com"})
    end tell
end tell


You can add to the script form fills and submit buttons with javascript:

do JavaScript "document.getElementById('field').value = '" &amp; myvalue &amp; "'"
do JavaScript "document.forms[\"form\"].submit();"


I'd try this out within the JavaScript console within a web browser first to make sure you have the names of everything correct.