Created
October 22, 2019 16:57
-
-
Save Moon4u/d0c4bbf84bc876986b3da1ea024b894f to your computer and use it in GitHub Desktop.
A ruby script that checks the popular skills required at stackoverflow's job posts.
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
require 'rss' | |
require 'open-uri' | |
# This is a simple script that goes through stackoverflow's rss feed for remote jobs and | |
# collects how many companies are looking for individual language/tool/skill. | |
# The script also displays relationship between each language/tool/skill. | |
# StackOverflow rss URL feed for remote jobs | |
SO_JOBS_RSS_URL = "https://stackoverflow.com/jobs/feed?r=true" | |
# StackOverlfow rss URL feed for remote c++ jobs only | |
SO_CPP_JOBS_RSS_URL = "https://stackoverflow.com/jobs/feed?r=true&tl=c%2b%2b" | |
# Maximum number of languages/tools/skills to display | |
DISPLAY_MAX = 10 | |
# Used to store languages/tools/skills | |
TECHNOLOGIES = {}; | |
class Technologies | |
def self.init | |
@@tech = {} | |
end | |
def self.increment( category ) | |
@@tech[ category ] = { :value => 0, :relations => {} } if( @@tech[ category ].nil? ) | |
@@tech[ category ][ :value ] += 1 | |
end | |
def self.addCategories( entry, categories ) | |
categories.each do | category | | |
next if( entry == category.content ) | |
str = category.content | |
@@tech[ entry ][ :relations ][ str ] = 0 if( @@tech[ entry ][ :relations ][ str ].nil? ) | |
@@tech[ entry ][ :relations ][ str ] += 1 | |
end | |
end | |
def self.display | |
@@tech.sort_by{ | k, v | v[ :value ] }.last( 10 ).each do | key, tech | | |
print "[#{ key }] #{ tech[ :value ] }\n" | |
tech[ :relations ].sort_by{ | k, v | v }.last( 10 ).reverse.each do | relation_key, relation_value | | |
break if( relation_value == 1 ) | |
print "\t[#{ relation_key }] #{ relation_value }\n" | |
end | |
end | |
end | |
end | |
Technologies.init | |
open( SO_JOBS_RSS_URL ) do | rss | | |
feed = RSS::Parser.parse( rss ) | |
feed.items.each do | item | | |
item.categories.each do | category | | |
Technologies.increment( category.content ) | |
Technologies.addCategories(category.content, item.categories ) | |
end | |
end | |
end | |
Technologies.display |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment