Skip to content

Instantly share code, notes, and snippets.

@tskogberg
Created October 12, 2012 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tskogberg/3882133 to your computer and use it in GitHub Desktop.
Save tskogberg/3882133 to your computer and use it in GitHub Desktop.
Slå upp ord i NE (www.ne.se)
# Slå upp ord i NE
require 'nokogiri'
require 'open-uri'
query_word = URI.encode('gamäng')
# alt doc.search('.ENC').text.lines.to_a[1].strip
doc = Nokogiri::HTML(open("http://www.ne.se/sok?q=#{query_word}"))
first_hit = doc.xpath('//span[@class="ENC"]').text.lines.map(&:strip)[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment