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.
Passing formatted text as an argument to a shortcut action
-
Imagine a shortcut action which is normally run from a share sheet in Safari and accepts the content of the currently displayed page as formatted text. But now I want to run the shortcut action programmatically from a Pythonista script, for a set of other web pages. I cannot find out how I can properly pass the content of these other pages as formatted text. If I pass the html, the markup gets processed verbatim - not what I want. I would like to pass the rendered version of the page.
Any help appreciated!
-
@kahlbutz could you pass it via the clipboard as it is text?
-
Are these urls? If so, you might check out
urlencode
:
https://docs.python.org/3/library/urllib.request.html#urllib-examples -
@kahlbutz, not 100% sure that I understand your issue, but if you want to pass the text of the page, without all the HTML tags, beautifulsoup can easily strip the tags.
-
-
It is easier to debug Python code than English prose... ;-)
-
Hi folks,
Thanks for your suggestions, but in the meantime I was able to solve the problem by sidestepping it. It struck me that I could extend the shortcut that I planned to run, by prepending the step Fetch contents of webpage from URL. The step could be named slightly differently, I only see the German name. Now the resulting Shortcut takes the URL, no longer the formatted text of the page. Super!
What still strikes me: I do this in a loop for several URLs. But the shortcut is only run for the first URL. Is this because the calls to the Shortcut app do not block, and the following ones happen while the first is still executing? Can I wait for its completion?
-
-
I think the fault lies in the generator expression on line 11.
-
@ccc It is strange that the fault is always in the same line nΒ°, isn't it?
-
@cvp, thatβs why I never have line 11 in my scripts.
-
Me neither https://github.com/cclauss/Ten-lines-or-less
-
@cvp many thanks, this did it! Proves that I am still a bloody novice in Shortcuts usage. Definitely worth digging deeper! Merry Christmas, everybody
-