Module: Rss::WWW

Defined in:
lib/rss-motor/www.rb

Class Method Summary collapse

Class Method Details

.http_requester(httpurl) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rss-motor/www.rb', line 15

def self.http_requester(httpurl)
  begin
    uri = URI.parse(httpurl)
    http = Net::HTTP.new(uri.host, uri.port)
    if httpurl.match(/^https:\/\//)
      http.use_ssl = true
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    end
    request = Net::HTTP::Get.new(uri.request_uri)
    response = http.request(request)
  rescue
    return ''
  end
  return '' if response.code.match(/^4/) || response.code.match(/^5/)
  return response.body if response['location'].nil?
  http_requester response['location']
end

.rss_channel(rssurl) ⇒ Object



10
11
12
13
# File 'lib/rss-motor/www.rb', line 10

def self.rss_channel(rssurl)
  xml = http_requester rssurl
  XMLMotor.get_node_from_content xml, 'rss.channel'
end