Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Web_scraper_noof_ques.rb
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions contest_list_web_scraper.rb
Original file line number Diff line number Diff line change
@@ -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