brwiki 0.1.1 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +34 -0
- data/Rakefile +4 -0
- data/builds/brwiki-0.2.gem +0 -0
- data/example/ex.rb +4 -0
- data/lib/brwiki/version.rb +3 -0
- data/lib/brwiki.rb +11 -62
- data/sig/brwiki.rbs +4 -0
- metadata +23 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c80fd4d1bcecd38c470ecd46f88eeede008ca4bf2933c7459d3fa60dc431f5fa
|
4
|
+
data.tar.gz: b008f4fda68b66b2bc2f02df5362dfd95f14b352f8841d14c80b1a3325586e79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3c22e153376e141853dcb1842c83bfd5f72a3d743061279dd527a125e0d391c9bb458cebc231003aaa0a79aaed673d7a38b968d849374917f4821e0ebfa1f29
|
7
|
+
data.tar.gz: 6bf76b6782405dc97bada1ce8d53726a1991c9dd9e22940c356d2399985ddc05b3724fc3180a61ce2d14ed62df646e6cbe85978e401be81debe576b171b351ca
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Brwiki
|
2
|
+
|
3
|
+
A library to scrap articles from wikipedia
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'brwiki'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install brwiki
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
|
25
|
+
include Brwiki
|
26
|
+
puts Brwiki::search("en","juice")
|
27
|
+
```
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/luizin5/brwiki.
|
31
|
+
|
32
|
+
## License
|
33
|
+
|
34
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
Binary file
|
data/example/ex.rb
ADDED
data/lib/brwiki.rb
CHANGED
@@ -1,69 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "nokogiri"
|
2
|
+
require "open-uri"
|
3
3
|
|
4
|
-
|
4
|
+
module Brwiki
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
attr_reader :site
|
11
|
-
attr_reader :sitehtml
|
12
|
-
attr_reader :lang
|
13
|
-
|
14
|
-
|
15
|
-
def setpage(artigo)
|
16
|
-
|
17
|
-
@lol = "https://#{@lang}.wikipedia.org"
|
18
|
-
|
19
|
-
@fonte = "https://#{@lang}.m.wikipedia.org/wiki/#{artigo}"
|
20
|
-
|
21
|
-
@site = HTTParty.get(@fonte)
|
22
|
-
|
23
|
-
@sitehtml = Nokogiri::HTML(@site.response.body)
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
def setlang(idioma)
|
30
|
-
@lang = idioma
|
31
|
-
|
32
|
-
return "idioma selecionado #{idioma}"
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def gettitle
|
38
|
-
return @sitehtml.search("title").text
|
6
|
+
def self.search lang, pesquisa
|
7
|
+
page = Nokogiri::HTML URI::open("https://#{lang}.m.wikipedia.org/wiki/#{pesquisa}")
|
8
|
+
[page.css("h1")[0].text,
|
9
|
+
fisrt_paragraph(page.css("p").to_a)[0].text]
|
39
10
|
end
|
40
11
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
if paragrafo.eql?("all")
|
45
|
-
return @sitehtml.search("p").text
|
46
|
-
else
|
47
|
-
p = @sitehtml.search("p")[paragrafo]
|
48
|
-
return p.text
|
49
|
-
end
|
12
|
+
private
|
13
|
+
def fisrt_paragraph x
|
14
|
+
x.reject { |y| y.attr("class") == "mw-empty-elt" }
|
50
15
|
end
|
51
16
|
|
52
|
-
|
53
|
-
|
54
|
-
def geturl
|
55
|
-
fonte = @fonte
|
56
|
-
return fonte
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
def getlinks(links)
|
62
|
-
if links == "all"
|
63
|
-
links = @sitehtml.search("a")
|
64
|
-
else
|
65
|
-
links = @sitehtml.search("a")[links]
|
66
|
-
end
|
67
|
-
return @lol + links.attr("href")
|
68
|
-
end
|
69
17
|
end
|
18
|
+
|
data/sig/brwiki.rbs
ADDED
metadata
CHANGED
@@ -1,79 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brwiki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- luizin5
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.13.9
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: nokogiri
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: httparty
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
description: obtenha paginas do wikipedia direto em seu terminal
|
70
|
-
email: luizfelip079@outlook.com
|
26
|
+
version: 1.13.9
|
27
|
+
description: a library to access articles from wikipedia
|
28
|
+
email:
|
29
|
+
- '='
|
71
30
|
executables: []
|
72
31
|
extensions: []
|
73
32
|
extra_rdoc_files: []
|
74
33
|
files:
|
34
|
+
- CHANGELOG.md
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE.txt
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- builds/brwiki-0.2.gem
|
40
|
+
- example/ex.rb
|
75
41
|
- lib/brwiki.rb
|
76
|
-
|
42
|
+
- lib/brwiki/version.rb
|
43
|
+
- sig/brwiki.rbs
|
44
|
+
homepage:
|
77
45
|
licenses:
|
78
46
|
- MIT
|
79
47
|
metadata:
|
@@ -86,15 +54,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
54
|
requirements:
|
87
55
|
- - ">="
|
88
56
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
57
|
+
version: 2.6.0
|
90
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
59
|
requirements:
|
92
60
|
- - ">="
|
93
61
|
- !ruby/object:Gem::Version
|
94
62
|
version: '0'
|
95
63
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
64
|
+
rubygems_version: 3.4.1
|
97
65
|
signing_key:
|
98
66
|
specification_version: 4
|
99
|
-
summary: wikipedia
|
67
|
+
summary: a library to access articles from wikipedia
|
100
68
|
test_files: []
|