summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorMatthias Hecker <mail@apoc.cc>2020-04-03 13:51:57 +0200
committerMatthias Hecker <mail@apoc.cc>2020-04-03 13:51:57 +0200
commit63314f4987d7acc8a39a3680320e339cc94da66b (patch)
tree47a6c50c750a85fba526b625569dd6bf4cc78ff3 /lib/rbot
parent7b792bea7a644309623d67b5d49528ae13da3e7b (diff)
plugin(search): fix wolfram and gdef, removed some
this removes gcount and gtime from the search plugin, google no longer provides this information easily
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/core/utils/httputil.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb
index f7871e5b..e629becb 100644
--- a/lib/rbot/core/utils/httputil.rb
+++ b/lib/rbot/core/utils/httputil.rb
@@ -29,6 +29,12 @@ rescue LoadError => e
EOC
end
+begin
+ require 'nokogiri'
+rescue LoadError => e
+ error "No nokogiri library found, some features might not be available!"
+end
+
# To handle Gzipped pages
require 'stringio'
require 'zlib'
@@ -163,6 +169,15 @@ module ::Net
return self.body_to_utf(self.decompress_body(partial))
end
+
+ def xpath(path)
+ document = Nokogiri::HTML.parse(self.body)
+ document.xpath(path)
+ end
+
+ def to_json
+ JSON::parse(self.body)
+ end
end
end
@@ -649,7 +664,11 @@ class HttpUtil
resp = get_response(uri, options, &block)
raise "http error: #{resp}" unless Net::HTTPOK === resp ||
Net::HTTPPartialContent === resp
- return resp.body
+ if options[:resp]
+ return resp
+ else
+ return resp.body
+ end
rescue Exception => e
error e
end