silly attempt to make calc plugin last longer before google totally breaks it
cookies are an attempt to make it less likely to realise cloudbot is a bot, and the IE user agent is to force it to use the legacy HTML we can actually parse
This commit is contained in:
parent
dabf61a520
commit
d3e5099dab
|
@ -6,9 +6,10 @@ from util import hook, http
|
|||
def calc(inp):
|
||||
"""calc <term> -- Calculate <term> with Google Calc."""
|
||||
|
||||
soup = http.get_soup('http://www.google.com/search', q=inp)
|
||||
soup = http.get_soup('http://www.google.com/search', q=inp, cookies=True, user_agent=http.ua_internetexplorer)
|
||||
|
||||
result = soup.find('h2', {'class': 'r'})
|
||||
|
||||
exponent = result.find('sup')
|
||||
if not result:
|
||||
return "Could not calculate '{}'".format(inp)
|
||||
|
|
Reference in a new issue