diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-08-28 13:02:29 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-08-28 13:02:29 +0200 |
commit | 7d51d43a4f03a7529f30ed71fa807e9279aec39a (patch) | |
tree | a5c0945af3c2527b7c6fd35d456214ce10d3f5ef | |
parent | 5270da00bb7974629a1c0697c0296dbd7b7c992b (diff) |
search plugin: update google search
-rw-r--r-- | data/rbot/plugins/search.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/data/rbot/plugins/search.rb b/data/rbot/plugins/search.rb index 3b0fac5f..595dab3c 100644 --- a/data/rbot/plugins/search.rb +++ b/data/rbot/plugins/search.rb @@ -17,7 +17,8 @@ GOOGLE_SEARCH = "http://www.google.com/search?oe=UTF-8&q=" GOOGLE_WAP_SEARCH = "http://www.google.com/m/search?hl=en&q=" -GOOGLE_WAP_LINK = /<a accesskey="(\d)" href=".*?u=(.*?)">(.*?)<\/a>/im +# GOOGLE_WAP_LINK = /<a accesskey="(\d)" href=".*?u=(.*?)">(.*?)<\/a>/im +GOOGLE_WAP_LINK = /<a href="(?:.*?u=(.*?)|(http:\/\/.*?))">(.*?)<\/a>/im GOOGLE_CALC_RESULT = %r{<img src=/images/calc_img\.gif(?: width=40 height=30 alt="")?>.*?<h2 class=r[^>]*><b>(.+?)</b>} GOOGLE_COUNT_RESULT = %r{<font size=-1>Results <b>1<\/b> - <b>10<\/b> of about <b>(.*)<\/b> for} GOOGLE_DEF_RESULT = %r{<p> (Web definitions for .*?)<br/>(.*?)<br/>(.*?)\s-\s+<a href} @@ -91,10 +92,11 @@ class SearchPlugin < Plugin end single ||= (results.length==1) urls = Array.new + n = 0 results = results[0...hits].map { |res| - n = res[0] + n += 1 t = Utils.decode_html_entities res[2].gsub(filter, '').strip - u = URI.unescape res[1] + u = URI.unescape(res[0] || res[1]) urls.push(u) single ? u : "#{n}. #{Bold}#{t}#{Bold}: #{u}" }.join(" | ") |