class Object
Public Instance Methods
check_regex( mashed_regex, value )
click to toggle source
# File lib/socialinvestigator/client/standalone_net.rb, line 426 def check_regex( mashed_regex, value ) regex,result = mashed_regex.split( /\\;/ ) md = Regexp.new( regex ).match( value ) if md if result result = result.gsub( /\\1/, (md[1] || "" )).gsub( /\\2/, (md[2] || "") ) else true end else false end end
find_domain( hostname )
click to toggle source
Look up the domain
# File lib/socialinvestigator/client/standalone_net.rb, line 113 def find_domain( hostname ) # puts "Looking for SOA of #{hostname}" dns = Dnsruby::Resolver.new soa = dns.query( hostname, "SOA" ).answer.select do |rr| rr.is_a? Dnsruby::RR::IN::SOA end return hostname if soa.length > 0 parts = hostname.split( /\./ ) return nil if parts.length <= 2 find_domain( parts.slice(1,100).join( "." ) ) end
find_id_path( links, regex )
click to toggle source
# File lib/socialinvestigator/client/standalone_net.rb, line 307 def find_id_path( links, regex ) links.collect do |link| if regex.match( link ) res = $1 || link if (res =~ /share/) nil else res end end end.select do |x| x end.uniq end
hrefs( links, filter_shared = false )
click to toggle source
# File lib/socialinvestigator/client/standalone_net.rb, line 295 def hrefs( links, filter_shared = false ) links.collect do |x| x['href'] end.select do |url| if filter_shared !(url =~ /share/) else true end end.uniq end
matching_links( parsed, regex )
click to toggle source
Look inside the body:
# File lib/socialinvestigator/client/standalone_net.rb, line 283 def matching_links( parsed, regex ) parsed.css( "a" ).collect do |x| if regex.match( x['href'] ) x else nil end end.select do |x| x end end