Created
December 23, 2014 14:52
-
-
Save mubix/b833671f8100f30899ac to your computer and use it in GitHub Desktop.
Parse Site List for RSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'feedbag' | |
require 'net/http' | |
source = Net::HTTP.get('ddosattackprotection.org', '/blog/cyber-security-blogs/') | |
body = source.split('"') | |
rss = [] | |
body.each_with_index do |ob, index| | |
if ob =~ /.*href=/ | |
begin | |
results = Feedbag.find(body[index+1]) | |
results.each do |feed| | |
rss << feed | |
end | |
rescue RuntimeError | |
puts "Switching to HTTPS" | |
results = Feedbag.find(body[index+1]).gsub("http","https") | |
results.each do |feed| | |
rss << feed | |
end | |
rescue | |
puts "Error found" | |
end | |
end | |
end | |
puts rss.uniq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment