Created
July 1, 2013 03:29
-
-
Save kkxlkkxllb/5898189 to your computer and use it in GitHub Desktop.
bing dict search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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