diff --git a/Web_scraper_noof_ques.rb b/Web_scraper_noof_ques.rb new file mode 100644 index 0000000..2dcf1df --- /dev/null +++ b/Web_scraper_noof_ques.rb @@ -0,0 +1,34 @@ +require "httparty" +require "nokogiri" +require "json" +require "pry" +require 'csv' + + + + +#No of Questions Solved +url = 'https://www.codechef.com/users/' +id = 'aman8050' +url = url + id +page1 = HTTParty.get(url) +parse_page1 = Nokogiri:: HTML(page1) + +print "No of Ques Solved on Codechef: " + +parse_page1.css('.sidebar-right').css('.maintable').css('.content').css('.wrapper').css('.inner-wrapper').css('.rounded-cr-header').css('.rounded-cr-footer').css('.cols-2').css('.content-wrapper').css('.profile').map do |a| + print a.css('table#problem_stats').css('tr')[1].css('td')[0].text +end + +print "\n" + +#No of Questions on SPOJ +url1 = 'http://www.spoj.com/users/' +id1 = 'aman8050' +url1 = url1 + id1 +page2 = HTTParty.get(url1) +parse_page2 = Nokogiri:: HTML(page2) + +print "No of Ques Solved on SPOJ: " + +print parse_page2.css('.content').css('.container').css('.row').css('.col-md-9').css('.col-md-12').css('.row').css('.col-md-6').css('.dl-horizontal').search('dd')[0].text \ No newline at end of file diff --git a/contest_list_web_scraper.rb b/contest_list_web_scraper.rb new file mode 100644 index 0000000..fc9d498 --- /dev/null +++ b/contest_list_web_scraper.rb @@ -0,0 +1,40 @@ +require "httparty" +require "nokogiri" +require "json" +require "pry" +require 'csv' + +page = HTTParty.get('https://www.codechef.com/contests') + +parse_page = Nokogiri::HTML(page) + + +##Present Contests Scraping of Codechef +print "PRESENT CONTESTS\n" +i = 0 +events_array = [] +parse_page.css('.content').css('.wrapper').css('.inner-wrapper').css('.rounded-cr-header').css('.rounded-cr-footer').css('#primary-content').css('.content-wrapper').css('.dataTable')[0].css('tbody').map do |a| + event = a.css('td').css('a').length + + while i < event do + print a.css('td').css('a')[i].text + ' ' + "http://www.codechef.com"+ a.css('td').css('a')[i]['href'] + print "\n" + i += 1 + end + +end + +print "FUTURE CONTESTS\n" +j = 0 +events_array1 = [] +parse_page.css('.content').css('.wrapper').css('.inner-wrapper').css('.rounded-cr-header').css('.rounded-cr-footer').css('#primary-content').css('.content-wrapper').css('.dataTable')[1].css('tbody').map do |a| + event1 = a.css('td').css('a').length + + while j < event1 do + print a.css('td').css('a')[j].text + ' ' + "http://www.codechef.com"+ a.css('td').css('a')[j]['href'] + print "\n" + j += 1 + end + +end +