lib/vimgolf_finder/parser.rb in vimgolf-finder-0.1.7 vs lib/vimgolf_finder/parser.rb in vimgolf-finder-0.1.8
- old
+ new
@@ -3,11 +3,11 @@
BASE_URL = 'http://vimgolf.com'
def fetch_challenges
challenges = []
- doc = Nokogiri::HTML(open(BASE_URL))
+ doc = Nokogiri::HTML(URI.open(BASE_URL))
doc.css('.grid_7 > div').each do |div|
challengeDOM = div.at_css('h5.challenge')
aTAG = challengeDOM.at_css('a')
challenge = VimGolfFinder::Challenge.new
challenge.id = aTAG['href'][12..-1]
@@ -20,18 +20,18 @@
end
def get_challenge(id)
challenge = VimGolfFinder::Challenge.new
- doc = Nokogiri::HTML(open("#{BASE_URL}/challenges/#{id}", 'Accept' => 'text/html'))
+ doc = Nokogiri::HTML(URI.open("#{BASE_URL}/challenges/#{id}", 'Accept' => 'text/html'))
doc.css('.grid_7:not(#about)').each do |dom|
challenge.id = id
challenge.title = dom.at_css('h3 b').content
challenge.description = dom.at_css('p').content
challenge.start_file = dom.at_css('.prettyprint').content
challenge.end_file = dom.css('.prettyprint')[1].content
- challenge.view_diff = dom.at_css('pre.diff').content
+ challenge.view_diff = dom.at_css('pre#diff').content
end
challenge
end
end
\ No newline at end of file