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
1 changed files with 2 additions and 1 deletions
|
@ -6,9 +6,10 @@ from util import hook, http
|
||||||
def calc(inp):
|
def calc(inp):
|
||||||
"""calc <term> -- Calculate <term> with Google Calc."""
|
"""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'})
|
result = soup.find('h2', {'class': 'r'})
|
||||||
|
|
||||||
exponent = result.find('sup')
|
exponent = result.find('sup')
|
||||||
if not result:
|
if not result:
|
||||||
return "Could not calculate '{}'".format(inp)
|
return "Could not calculate '{}'".format(inp)
|
||||||
|
|
Reference in a new issue