old_contents: import re
  
  from util import hook, http
  
  
  @hook.command
  def calc(inp):
      '''.calc <term> -- returns Google Calculator result'''
  
      page = http.get('http://www.google.com/search', q=inp)
  
      # ugh, scraping HTML with regexes
      m = re.search(r'<h2 class=r style="font-size:138%"><b>(.*?)</b>', page)
  
      if m is None:
          return "could not calculate " + inp
  
      result = m.group(1).replace("<font size=-2> </font>", ",")
      result = result.replace(" &#215; 10<sup>", "E").replace("</sup>", "")
      result = result.replace("\xa0", ",")
      return result
  
new_contents: from util import hook, http
  
  
  @hook.command
  def calc(inp):
      '''.calc <term> -- returns Google Calculator result'''
  
      h = http.get_html('http://www.google.com/search', q=inp)
  
      m = h.xpath('//h2[@class="r"]/text()')
  
      if not m:
          return "could not calculate " + inp
  
      res = ' '.join(m[0].split())
  
      return res
  
subject: update .calc to use lxml, fixes #44