Last active
January 2, 2016 10:08
-
-
Save h2rd/8287317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # echo '{ "title": "Бумажки: простая игра на сегодняшний вечер / Блог компании Мосигра / Хабрахабр", "url": "http://habrahabr.ru/company/mosigra/blog/207906/" }' | python json2query.py | pbcopy | |
| # curl -d'url=http%3A%2F%2Fhabrahabr.ru%2Fcompany%2Fmosigra%2Fblog%2F207906%2F&title=%D0%91%D1%83%D0%BC%D0%B0%D0%B6%D0%BA%D0%B8%3A+%D0%BF%D1%80%D0%BE%D1%81%D1%82%D0%B0%D1%8F+%D0%B8%D0%B3%D1%80%D0%B0+%D0%BD%D0%B0+%D1%81%D0%B5%D0%B3%D0%BE%D0%B4%D0%BD%D1%8F%D1%88%D0%BD%D0%B8%D0%B9+%D0%B2%D0%B5%D1%87%D0%B5%D1%80+%2F+%D0%91%D0%BB%D0%BE%D0%B3+%D0%BA%D0%BE%D0%BC%D0%BF%D0%B0%D0%BD%D0%B8%D0%B8+%D0%9C%D0%BE%D1%81%D0%B8%D0%B3%D1%80%D0%B0+%2F+%D0%A5%D0%B0%D0%B1%D1%80%D0%B0%D1%85%D0%B0%D0%B1%D1%80' http://localhost:3333/page | |
| import sys | |
| import urllib | |
| import json | |
| def main(source): | |
| source = json.loads(source) | |
| source = dict(((k, v.encode('utf8')) for k, v in source.iteritems())) | |
| return urllib.urlencode(source) | |
| if __name__ == '__main__': | |
| print main(sys.stdin.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment