Sha256: 053bfcd77a5e52f1362c0beb2ab51990c44590d042df30bc81d2ef22f5c9de85
Contents?: true
Size: 754 Bytes
Versions: 26
Compression:
Stored size: 754 Bytes
Contents
#!/usr/bin/env ruby scrappers = [] results = [] class QuotedUrlScrapper REGEX = /"\w+:\/\/[^"]+"/ def initialize(text) @text = text end def get_urls @text.scan(REGEX).map do |url| url.chop! url.reverse.chop.reverse end end end class TextUrlScrapper REGEX = /\w+:\/\/[^\s]+/ def initialize(text) @text = text end def get_urls @text.scan(REGEX).map do |url| url.gsub!(/".*/, '') url.gsub!(/'.*/, '') end end end scrappers.push(QuotedUrlScrapper) scrappers.push(TextUrlScrapper) STDIN.each_line do |line| scrappers.each do |scrapper| parser = scrapper.new(line) parser.get_urls.each do |url| results << url end end end results.uniq.each do |url| puts url end
Version data entries
26 entries across 26 versions & 1 rubygems