Skip to content

Instantly share code, notes, and snippets.

@kkxlkkxllb
Created July 1, 2013 03:29
Show Gist options
  • Select an option

  • Save kkxlkkxllb/5898189 to your computer and use it in GitHub Desktop.

Select an option

Save kkxlkkxllb/5898189 to your computer and use it in GitHub Desktop.
bing dict search
def self.bing(text)
url = "http://cn.bing.com/dict/search?q=#{text}"
@client = Mechanize.new{ |agent|
agent.user_agent_alias = "Mac Safari" #"Windows Mozilla"
}
@client.get(url) do |page|
#p (page/'div.sen_en').collect{|x| x.text}
p (page/'div.se_li1').map{|x|
{
en: x.at(".sen_en").text,
cn: x.at(".sen_cn").text
}
}
end
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment