removed try/except from ripbang userscript
This commit is contained in:
parent
8169d1865a
commit
a716861bfa
@ -4,28 +4,24 @@
|
|||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# :spawn --userscript ripbang [bang]...
|
# :spawn --userscript ripbang [bang]...
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# :spawn --userscript ripbang amazon maps
|
# :spawn --userscript ripbang amazon maps
|
||||||
#
|
#
|
||||||
import os, re, requests, sys, urllib
|
import os, re, requests, sys, urllib
|
||||||
|
|
||||||
try:
|
for argument in sys.argv[1:]:
|
||||||
for argument in sys.argv[1:]:
|
bang = '!' + argument
|
||||||
bang = '!' + argument
|
r = requests.get('https://duckduckgo.com/',
|
||||||
r = requests.get('https://duckduckgo.com/', params={'q': bang + ' SEARCHTEXT'})
|
params={'q': bang + ' SEARCHTEXT'})
|
||||||
|
|
||||||
searchengine = urllib.unquote(re.search("url=[^']+", r.text).group(
|
searchengine = urllib.unquote(re.search("url=[^']+", r.text).group(0))
|
||||||
0))
|
searchengine = searchengine.replace('url=', '')
|
||||||
searchengine = searchengine.replace('url=', '')
|
searchengine = searchengine.replace('/l/?kh=-1&uddg=', '')
|
||||||
searchengine = searchengine.replace('/l/?kh=-1&uddg=', '')
|
searchengine = searchengine.replace('SEARCHTEXT', '{}')
|
||||||
searchengine = searchengine.replace('SEARCHTEXT', '{}')
|
|
||||||
|
|
||||||
if os.getenv('QUTE_FIFO'):
|
if os.getenv('QUTE_FIFO'):
|
||||||
with open(os.environ['QUTE_FIFO'], 'w') as fifo:
|
with open(os.environ['QUTE_FIFO'], 'w') as fifo:
|
||||||
fifo.write('set searchengines %s %s' % (bang, searchengine))
|
fifo.write('set searchengines %s %s' % (bang, searchengine))
|
||||||
else:
|
else:
|
||||||
print '%s %s' % (bang, searchengine)
|
print '%s %s' % (bang, searchengine)
|
||||||
except:
|
|
||||||
# fail silent
|
|
||||||
exit(1)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user