-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcontest_list_web_scraper.rb
More file actions
40 lines (30 loc) · 1.12 KB
/
contest_list_web_scraper.rb
File metadata and controls
40 lines (30 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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