Google changed their layout again. To be a little more future-proof,
split the html into as many <br/> sections as there are, and pick the
first one that contains the literal string ' = ' if there is one.
debug "#{html.size} bytes of html recieved"
- intro, result, junk = html.split(/\s*<br\/>\s*/, 3)
- debug "result: #{result.inspect}"
+ splits = html.split(/\s*<br\/>\s*/)
+ candidates = splits.select { |section| section.include? ' = ' }
+ debug "candidates: #{candidates.inspect}"
- unless result.include? '='
+ if candidates.empty?
m.reply "couldn't calculate #{what}"
return
end
+ result = candidates.first
debug "replying with: #{result.inspect}"
m.reply result.ircify_html