From 08f5ef4d38f11d09240773039a2acb7683cc7e3a Mon Sep 17 00:00:00 2001 From: aman8050 Date: Sun, 12 Feb 2017 16:25:47 +0530 Subject: [PATCH 1/3] Scraper to find no of questions solved by user --- Web_scraper_noof_ques.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Web_scraper_noof_ques.rb diff --git a/Web_scraper_noof_ques.rb b/Web_scraper_noof_ques.rb new file mode 100644 index 0000000..8bf81dc --- /dev/null +++ b/Web_scraper_noof_ques.rb @@ -0,0 +1,23 @@ +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: " + +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 + + From 5aabf74caf55138f3edd8536a84fb58df72e0fb9 Mon Sep 17 00:00:00 2001 From: aman8050 Date: Mon, 13 Feb 2017 11:28:16 +0530 Subject: [PATCH 2/3] Scraper to fetch Present and Future contest from codechef --- contest_list_web_scraper.rb | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 contest_list_web_scraper.rb 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 + From 92b54a7664cb032d1b0329b428d61b33693fdb29 Mon Sep 17 00:00:00 2001 From: aman8050 Date: Mon, 13 Feb 2017 12:33:24 +0530 Subject: [PATCH 3/3] Added no of questions solved on SPOJ --- Web_scraper_noof_ques.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Web_scraper_noof_ques.rb b/Web_scraper_noof_ques.rb index 8bf81dc..2dcf1df 100644 --- a/Web_scraper_noof_ques.rb +++ b/Web_scraper_noof_ques.rb @@ -14,10 +14,21 @@ page1 = HTTParty.get(url) parse_page1 = Nokogiri:: HTML(page1) -print "No of Ques Solved: " +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