diff --git a/misc/userscripts/ripbang b/misc/userscripts/ripbang index 3a083cad3..4b418443d 100755 --- a/misc/userscripts/ripbang +++ b/misc/userscripts/ripbang @@ -4,28 +4,24 @@ # # Usage: # :spawn --userscript ripbang [bang]... -# +# # Example: # :spawn --userscript ripbang amazon maps # import os, re, requests, sys, urllib -try: - for argument in sys.argv[1:]: - bang = '!' + argument - r = requests.get('https://duckduckgo.com/', params={'q': bang + ' SEARCHTEXT'}) +for argument in sys.argv[1:]: + bang = '!' + argument + r = requests.get('https://duckduckgo.com/', + params={'q': bang + ' SEARCHTEXT'}) - searchengine = urllib.unquote(re.search("url=[^']+", r.text).group( - 0)) - searchengine = searchengine.replace('url=', '') - searchengine = searchengine.replace('/l/?kh=-1&uddg=', '') - searchengine = searchengine.replace('SEARCHTEXT', '{}') + searchengine = urllib.unquote(re.search("url=[^']+", r.text).group(0)) + searchengine = searchengine.replace('url=', '') + searchengine = searchengine.replace('/l/?kh=-1&uddg=', '') + searchengine = searchengine.replace('SEARCHTEXT', '{}') - if os.getenv('QUTE_FIFO'): - with open(os.environ['QUTE_FIFO'], 'w') as fifo: - fifo.write('set searchengines %s %s' % (bang, searchengine)) - else: - print '%s %s' % (bang, searchengine) -except: - # fail silent - exit(1) + if os.getenv('QUTE_FIFO'): + with open(os.environ['QUTE_FIFO'], 'w') as fifo: + fifo.write('set searchengines %s %s' % (bang, searchengine)) + else: + print '%s %s' % (bang, searchengine)