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 +4 -4
- data/README.md +7 -0
- data/lib/bing_dictionary.rb +16 -2
- data/lib/bing_dictionary/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cad16aa4d9efe86a2c0aadbdbf90132184b6ba5d63ba6f38f637ae2189591b2
|
4
|
+
data.tar.gz: 56b07543646bfd3535f50c3d25fd25377c66e46919ec6f4889c82e87ba4fe72c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/bing_dictionary.rb
CHANGED
@@ -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
|
-
|
32
|
+
body = self.request(word)
|
19
33
|
self.word = word
|
20
|
-
self.doc = Nokogiri::HTML(
|
34
|
+
self.doc = Nokogiri::HTML(body)
|
21
35
|
self.options = options
|
22
36
|
end
|
23
37
|
|
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.
|
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-
|
11
|
+
date: 2021-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|