bing_dictionary 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81839a4a2c0db47ca6748695874d665d5da117275e8008ebb9d30d258e794ca8
4
- data.tar.gz: a907576387cbf7d109bcc14ff97c9ee97d9e3da695b8ad6427345952c0a3b58e
3
+ metadata.gz: 1cad16aa4d9efe86a2c0aadbdbf90132184b6ba5d63ba6f38f637ae2189591b2
4
+ data.tar.gz: 56b07543646bfd3535f50c3d25fd25377c66e46919ec6f4889c82e87ba4fe72c
5
5
  SHA512:
6
- metadata.gz: 342c0525ed961f9d6b4c2f4c7aa71a90f1e57ac980d37cabc89d625b2c38211e6026e175ef2df3d9866a92494442084f2b26501c6faff2e8e679c9c141708ff3
7
- data.tar.gz: cef434ed6cc6b22ce04e0c9b777943e4af2c29819984ead8826e48ac08ac170c6b80691f9f980e815d40d4877c7d814380140e5863de6a6339eaf316a21adaca
6
+ metadata.gz: b96c361ef65d1d323b9a71ffd13d6eb22f5c7a5cd2c3f498f0ebcfce6ce9ca0ef2fe35957612602a47b53f8218ff3aa10b1acffbb690140fb7702d96dc7584a6
7
+ data.tar.gz: 41e6c58cf8de625c69c17fa1ac5dc69254606c37ee273c5e6db84b2943dd0923298ae853734cc20440d9ca8a810ba12b0ec0472e5049ffcc406ca1856eb33871
data/README.md CHANGED
@@ -75,6 +75,13 @@ Heavily borrowed from [Command-Line-Youdao-Dictionary](https://github.com/qhwa/C
75
75
 
76
76
  bundle exec ./bin/dict --no-cache hello
77
77
 
78
+ // Install gem in local
79
+ rake install
80
+ // Build new version
81
+ rake build
82
+ // Build new gem and publish to https://rubygems.org
83
+ rake release
84
+
78
85
  ## Contributing
79
86
 
80
87
  Bug reports and pull requests are welcome on GitHub at https://github.com/lingceng/bing_dictionary. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -2,6 +2,8 @@ require 'nokogiri'
2
2
  require 'open-uri'
3
3
  require 'cgi'
4
4
  require "bing_dictionary/version"
5
+ require "uri"
6
+ require "net/http"
5
7
 
6
8
  module BingDictionary
7
9
  class Base
@@ -14,10 +16,22 @@ module BingDictionary
14
16
  exit 1
15
17
  end
16
18
 
19
+ def request(word)
20
+ url = URI("https://cn.bing.com/dict/search?q=#{CGI::escape(word)}")
21
+
22
+ https = Net::HTTP.new(url.host, url.port)
23
+ https.use_ssl = true
24
+ request = Net::HTTP::Get.new(url)
25
+ request["Cookie"] = "_EDGE_S=mkt=zh-cn;"
26
+
27
+ response = https.request(request)
28
+ return response.read_body
29
+ end
30
+
17
31
  def initialize(word, options = {})
18
- file = URI.open("http://cn.bing.com/dict/?q=#{CGI::escape(word)}")
32
+ body = self.request(word)
19
33
  self.word = word
20
- self.doc = Nokogiri::HTML(file)
34
+ self.doc = Nokogiri::HTML(body)
21
35
  self.options = options
22
36
  end
23
37
 
@@ -1,3 +1,3 @@
1
1
  module BingDictionary
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bing_dictionary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - lingceng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-24 00:00:00.000000000 Z
11
+ date: 2021-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler