Skip to content

Instantly share code, notes, and snippets.

@drdrang
Created February 12, 2009 17:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drdrang/62753 to your computer and use it in GitHub Desktop.
Save drdrang/62753 to your computer and use it in GitHub Desktop.
-- A function for escaping URLs and skeleton code for a test.
on URLescape(myURL)
set myURL to quoted form of myURL
set myURL to text from character 2 to -2 of myURL
set cmd to "
from urllib import quote
print quote(\"" & myURL & "\", \"/:\")
"
--return cmd
return (do shell script "python -c '" & cmd & "'")
end URLescape
set test to "Here's a string with quotes & ampersands"
URLescape(test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment