Added referer field to http.py, as to make it possible to use a referer. I
don't know if this was possible before, and if it was it should be removed and the appropriate changes should be made without the http.py change. Stock plugin output was changed so the percent change has an actual percentage sign after it. UrbanDictionary plugin was changed to use a referer because it didn't work without it.
This commit is contained in:
parent
b3b85e6183
commit
68e5535ca4
|
@ -9,7 +9,7 @@ def urban(inp):
|
||||||
'''.u/.urban <phrase> -- looks up <phrase> on urbandictionary.com'''
|
'''.u/.urban <phrase> -- looks up <phrase> on urbandictionary.com'''
|
||||||
|
|
||||||
url = 'http://www.urbandictionary.com/iphone/search/define'
|
url = 'http://www.urbandictionary.com/iphone/search/define'
|
||||||
page = http.get_json(url, term=inp)
|
page = http.get_json(url, term=inp, referer="http://m.urbandictionary.com")
|
||||||
defs = page['list']
|
defs = page['list']
|
||||||
|
|
||||||
if page['result_type'] == 'no_results':
|
if page['result_type'] == 'no_results':
|
||||||
|
|
|
@ -28,7 +28,7 @@ def stock(inp):
|
||||||
results['color'] = "3"
|
results['color'] = "3"
|
||||||
|
|
||||||
ret = "%(company)s - %(last)s %(currency)s " \
|
ret = "%(company)s - %(last)s %(currency)s " \
|
||||||
"\x03%(color)s%(change)s (%(perc_change)s)\x03 " \
|
"\x03%(color)s%(change)s (%(perc_change)s%%)\x03 " \
|
||||||
"as of %(trade_timestamp)s" % results
|
"as of %(trade_timestamp)s" % results
|
||||||
|
|
||||||
if results['delay'] != '0':
|
if results['delay'] != '0':
|
||||||
|
|
|
@ -37,7 +37,7 @@ def get_json(*args, **kwargs):
|
||||||
return json.loads(get(*args, **kwargs))
|
return json.loads(get(*args, **kwargs))
|
||||||
|
|
||||||
|
|
||||||
def open(url, query_params=None, user_agent=None, post_data=None,
|
def open(url, query_params=None, user_agent=None, referer=None, post_data=None,
|
||||||
get_method=None, cookies=False, **kwargs):
|
get_method=None, cookies=False, **kwargs):
|
||||||
|
|
||||||
if query_params is None:
|
if query_params is None:
|
||||||
|
@ -57,6 +57,9 @@ def open(url, query_params=None, user_agent=None, post_data=None,
|
||||||
|
|
||||||
request.add_header('User-Agent', user_agent)
|
request.add_header('User-Agent', user_agent)
|
||||||
|
|
||||||
|
if referer is not None:
|
||||||
|
request.add_header('Referer', referer)
|
||||||
|
|
||||||
if cookies:
|
if cookies:
|
||||||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
|
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue