omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. lunkan49

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    lunkan49

    @lunkan49

    0
    Reputation
    677
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    lunkan49 Unfollow Follow

    Latest posts made by lunkan49

    • Safari Bookmarklet to run python script

      Hello!
      I made a simple script to demonstrate how to create a bookmarklet in safari that calls a python script in pythonista and passes the current safari URL as a parameter to that script.
      It's not rocket science, you can figure out the details yourself.

      This is the JavaScript code you should use to create the bookmark. DoStuff is the name of the python script that is run in my example:

      <pre>
      javascript:(function(){if(document.location.href.indexOf('http')===0)document.location.href='pythonista://DoStuff?action=run&argv='+document.location.href;})();
      </pre>

      Now for the simple script. It just prints out the params passed to it except the name of the script itself:

      <pre>
      #DoStuff.py

      import sys
      import pprint
      import console

      console.clear()

      pprint.pprint(sys.argv[1:])
      </pre>

      You get the idea! Lets go nuts! :)

      posted in Pythonista
      lunkan49
      lunkan49
    • RE: Safari Bookmarklet to run python script

      Lets see if you can see the JavaScript line better if I don't put it in code-blocks!

      javascript:(function(){if(document.location.href.indexOf('http')===0)document.location.href='pythonista://DoStuff?action=run&argv='+document.location.href;})();

      I just made a bookmarklet that parses all image URLs from a web page and copies them to the clipboard. The combo of input through Safari and JavaScript and output to clipboard is quite powerful. You don't have to stop there since you can forward the result to other apps that have URL-schemes for input.

      posted in Pythonista
      lunkan49
      lunkan49