Skip to content

Commit

Permalink
removed some duplication from Rakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Gega (pietia) committed Jul 24, 2012
1 parent fded53f commit 2d75690
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions Rakefile
Expand Up @@ -56,21 +56,17 @@ namespace :utils do
# scrapes eurucamp page on lanyrd.com and returns
# array of Twitter names
def lanyrd_attendees
base_url = 'http://lanyrd.com/2012/eurucamp/attendees/'
profile_selector = '.primary .mini-profile .name a'
first_page = Nokogiri::HTML(open(base_url))
attendees = first_page.css(profile_selector).map {|a| a['href'].gsub(/^\/profile\/|\/$/,'') }
profile_selector = '.primary .mini-profile .name a'.freeze
pagination_selector = '.pagination li a'.freeze
base_url = 'http://lanyrd.com'.freeze
first_page_path = '/2012/eurucamp/attendees/'.freeze

other_pages_selector = '.pagination li a'
other_pages = first_page.css(other_pages_selector).map do |a|
'http://lanyrd.com' + a[:href]
end

other_pages.each do |page|
page = Nokogiri::HTML(open(page))
attendees += page.css(profile_selector).map {|a| a['href'].gsub(/^\/profile\/|\/$/,'') }
end
first_page = Nokogiri::HTML(open(base_url + first_page_path))
other_pages_paths = first_page.css(pagination_selector).map { |a| a[:href] }

attendees
(other_pages_paths << first_page_path).map do |relative_path|
page = Nokogiri::HTML(open(base_url + relative_path))
page.css(profile_selector).map {|a| a['href'].gsub(/^\/profile\/|\/$/,'') }
end.flatten.sort
end
end

0 comments on commit 2d75690

Please sign in to comment.