tomosia_icon8_crawl 0.1.0 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +11 -11
- data/.rspec +3 -3
- data/.travis.yml +6 -6
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile +9 -9
- data/Gemfile.lock +1 -1
- data/LICENSE.txt +21 -21
- data/README.md +37 -1
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/tomosia_icon8_crawl.rb +151 -148
- data/lib/tomosia_icon8_crawl/cli.rb +1 -1
- data/lib/tomosia_icon8_crawl/version.rb +3 -3
- data/spec/spec_helper.rb +18 -18
- data/spec/tomosia_icon8_crawl_spec.rb +9 -9
- data/tomosia_icon8_crawl.gemspec +29 -29
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f31b322adad997e3fc62c5fb47c4c9c5053f8b56ce58843918de189b64bbebd
|
4
|
+
data.tar.gz: 35c6ee6157c954c09fc5223a33b909268bb6a00c9040734accee4881c6f7f4e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7a13abfab173d318d405756a5d6637865d4eed4b0b8808690e81284d46dee3bc90deecfc691e3ef7e8e880984bf69bd5c0b2439d538581e3f25563f7aa0eae0
|
7
|
+
data.tar.gz: 8ce5c215458327b2723e40679c2463146f216149cc90b0157edd4d1cf235681a7daa08fb45421233b5eb1636100b3daa33ab59f550e918d69eb668978b5a7e95
|
data/.gitignore
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/_yardoc/
|
4
|
-
/coverage/
|
5
|
-
/doc/
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/tmp/
|
9
|
-
|
10
|
-
# rspec failure tracking
|
11
|
-
.rspec_status
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
|
10
|
+
# rspec failure tracking
|
11
|
+
.rspec_status
|
data/.rspec
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
--format documentation
|
2
|
-
--color
|
3
|
-
--require spec_helper
|
1
|
+
--format documentation
|
2
|
+
--color
|
3
|
+
--require spec_helper
|
data/.travis.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
---
|
2
|
-
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
rvm:
|
5
|
-
- 2.7.1
|
6
|
-
before_install: gem install bundler -v 2.1.4
|
1
|
+
---
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
rvm:
|
5
|
+
- 2.7.1
|
6
|
+
before_install: gem install bundler -v 2.1.4
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at tt.ninh.le@tomosia.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: https://contributor-covenant.org
|
74
|
-
[version]: https://contributor-covenant.org/version/1/4/
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at tt.ninh.le@tomosia.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in tomosia_icon8_crawl.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem "rake", "~> 12.0"
|
7
|
-
gem "rspec", "~> 3.0"
|
8
|
-
gem 'writeexcel', '~> 1.0', '>= 1.0.5'
|
9
|
-
gem 'pry', '~> 0.13.1'
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in tomosia_icon8_crawl.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "rake", "~> 12.0"
|
7
|
+
gem "rspec", "~> 3.0"
|
8
|
+
gem 'writeexcel', '~> 1.0', '>= 1.0.5'
|
9
|
+
gem 'pry', '~> 0.13.1'
|
10
10
|
gem 'httparty', '~> 0.17.3'
|
data/Gemfile.lock
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2020 ninh-tomosia
|
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.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 ninh-tomosia
|
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
CHANGED
@@ -22,7 +22,43 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
### Commandline or Terminal:
|
26
|
+
|
27
|
+
Download all photos including pages from icon8.com with keyword you search
|
28
|
+
|
29
|
+
$ tomosia_icon8_crawl crawl "keyword" --destination="storage path"
|
30
|
+
|
31
|
+
Download pictures with number you want to get from icon8.com with keyword to find
|
32
|
+
|
33
|
+
$ tomosia_icon8_crawl crawl "keyword" --destination="storage path" --max=number
|
34
|
+
|
35
|
+
### Developers:
|
36
|
+
|
37
|
+
Gemfile:
|
38
|
+
|
39
|
+
$ gem 'tomosia_icon8_crawl'
|
40
|
+
|
41
|
+
Require:
|
42
|
+
|
43
|
+
$ require 'tomosia_icon8_crawl'
|
44
|
+
|
45
|
+
Download all photos including pages from icon8.com with keyword you search
|
46
|
+
|
47
|
+
$ TomosiaIcon8Crawl::CrawlIcon8.crawl("keyword", "destination")
|
48
|
+
|
49
|
+
Download pictures with number you want to get from icon8.com with keyword to find
|
50
|
+
|
51
|
+
$ TomosiaIcon8Crawl::CrawlIcon8.crawl("keyword", "destination", max)
|
52
|
+
|
53
|
+
Help:
|
54
|
+
- keyword is the word used for searching.
|
55
|
+
ex: corona, car, virus,...
|
56
|
+
- destination is the path of the directory where the image was downloaded.
|
57
|
+
ex: E:\download, C:\download, C:\Desktop,...
|
58
|
+
- max max is the number of images you want to download.
|
59
|
+
ex: 100, 10, 5, 1000,...
|
60
|
+
|
61
|
+
|
26
62
|
|
27
63
|
## Development
|
28
64
|
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
|
6
|
-
task :default => :spec
|
7
|
-
namespace :gem do
|
8
|
-
task :build do
|
9
|
-
system "rake build && rake install"
|
10
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
7
|
+
namespace :gem do
|
8
|
+
task :build do
|
9
|
+
system "rake build && rake install"
|
10
|
+
end
|
11
11
|
end
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "tomosia_icon8_crawl"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "tomosia_icon8_crawl"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/lib/tomosia_icon8_crawl.rb
CHANGED
@@ -1,149 +1,152 @@
|
|
1
|
-
module TomosiaIcon8Crawl
|
2
|
-
require 'open-uri'
|
3
|
-
require "HTTParty"
|
4
|
-
require 'pry'
|
5
|
-
require 'WriteExcel'
|
6
|
-
class CrawlIcon8
|
7
|
-
|
8
|
-
# get data from website
|
9
|
-
def self.json(key, max)
|
10
|
-
if key == nil
|
11
|
-
p "No data!"
|
12
|
-
else
|
13
|
-
if max == nil
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
worksheet.write_string(i,
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
1
|
+
module TomosiaIcon8Crawl
|
2
|
+
require 'open-uri'
|
3
|
+
require "HTTParty"
|
4
|
+
require 'pry'
|
5
|
+
require 'WriteExcel'
|
6
|
+
class CrawlIcon8
|
7
|
+
|
8
|
+
# get data from website
|
9
|
+
def self.json(key, max)
|
10
|
+
if key == nil
|
11
|
+
p "No data!"
|
12
|
+
else
|
13
|
+
if max == nil
|
14
|
+
urlc = 'https://search.icons8.com/api/iconsets/v5/search?term=' + key + '&amount=1'
|
15
|
+
page = HTTParty.get(urlc)
|
16
|
+
res = page.parsed_response
|
17
|
+
countAll = res['parameters']['countAll']
|
18
|
+
url = 'https://search.icons8.com/api/iconsets/v5/search?term=' + key + '&amount=' + countAll
|
19
|
+
else
|
20
|
+
url = 'https://search.icons8.com/api/iconsets/v5/search?term=' + key + '&amount=' + max
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
page_data = HTTParty.get(url)
|
25
|
+
@responses = page_data.parsed_response
|
26
|
+
end
|
27
|
+
|
28
|
+
# save file to txt
|
29
|
+
def self.save_file_txt(index, name, url, size, extension)
|
30
|
+
File.open("log_image.txt", "a+") do |f|
|
31
|
+
f.write("#{index}. name: #{name} | url: #{url} | size: #{size}Kb | extension: #{extension} \n")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# save file to excel
|
36
|
+
def self.save_file_excel( path, data = {})
|
37
|
+
begin
|
38
|
+
des = path + '/export.xls'
|
39
|
+
workbook = WriteExcel.new(des)
|
40
|
+
format = workbook.add_format
|
41
|
+
format.set_bold()
|
42
|
+
format.set_align('center')
|
43
|
+
|
44
|
+
data_col = workbook.add_format
|
45
|
+
data_col.set_align('center')
|
46
|
+
format_url = workbook.add_format
|
47
|
+
format_url.set_color('blue')
|
48
|
+
format_url.set_align('center')
|
49
|
+
|
50
|
+
worksheet = workbook.add_worksheet
|
51
|
+
|
52
|
+
worksheet.write_string(0, 0, 'STT', format)
|
53
|
+
worksheet.write_string(0, 1, 'NAME', format)
|
54
|
+
worksheet.write_string(0, 2, 'URL', format)
|
55
|
+
worksheet.write_string(0, 3, 'SIZE(byte)', format)
|
56
|
+
worksheet.write_string(0, 4, 'EXTENSION', format)
|
57
|
+
|
58
|
+
multi = []
|
59
|
+
data.each_with_index do |row, index|
|
60
|
+
i = index + 1
|
61
|
+
# p i
|
62
|
+
# p row
|
63
|
+
multi << Thread.new do
|
64
|
+
row.each do |key, value|
|
65
|
+
# p key
|
66
|
+
|
67
|
+
worksheet.write_string(i, 0, row['index'].to_s, data_col)
|
68
|
+
worksheet.write_string(i, 1, row['name'], data_col)
|
69
|
+
worksheet.write_url(i, 2, row['url'], format_url)
|
70
|
+
worksheet.write_string(i, 3, row['size'].to_s, data_col)
|
71
|
+
worksheet.write_string(i, 4, row['extension'], data_col)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
multi.each{ |m| m.join }
|
76
|
+
|
77
|
+
workbook.close
|
78
|
+
rescue Exception => e
|
79
|
+
p "Can't saved file"
|
80
|
+
# p e
|
81
|
+
# break
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# download image
|
86
|
+
def self.download_image(path, img)
|
87
|
+
timeout = 0
|
88
|
+
begin
|
89
|
+
open(img) do |image|
|
90
|
+
File.open(path, 'wb') do |file|
|
91
|
+
file.write(image.read)
|
92
|
+
@size = image.size
|
93
|
+
# p @size
|
94
|
+
end
|
95
|
+
end
|
96
|
+
rescue
|
97
|
+
if timeout < 5
|
98
|
+
timeout += 1
|
99
|
+
p "Retry download image"
|
100
|
+
retry
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# multi download image
|
106
|
+
def self.multi_download_image(path, imgs)
|
107
|
+
begin
|
108
|
+
threads = []
|
109
|
+
@data = []
|
110
|
+
|
111
|
+
imgs.each_with_index do |img, index|
|
112
|
+
# p index
|
113
|
+
title = File.basename(img, '.png')
|
114
|
+
des = path. + "/" + index.to_s + "-" + title + ".png"
|
115
|
+
ext = File.extname(img).delete('.')
|
116
|
+
threads << Thread.new do
|
117
|
+
download_image(des, img)
|
118
|
+
row = {"index" => index, "name" => title, "url" => img, "size" => @size, "extension" => ext}
|
119
|
+
@data.push(row)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
threads.each{ |t| t.join }
|
123
|
+
rescue Exception => e
|
124
|
+
p "no data"
|
125
|
+
p e
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# main
|
130
|
+
def self.crawl(keyword = nil, path = ".", max = nil)
|
131
|
+
begin
|
132
|
+
|
133
|
+
images = []
|
134
|
+
des = ""
|
135
|
+
json(keyword, max)
|
136
|
+
@responses['icons'].each_with_index do |item, index|
|
137
|
+
|
138
|
+
src = "https://img.icons8.com/#{item['platform']}/2x/#{item['commonName']}.png"
|
139
|
+
|
140
|
+
# add image
|
141
|
+
images.push(src)
|
142
|
+
end
|
143
|
+
|
144
|
+
multi_download_image(path, images)
|
145
|
+
save_file_excel(path, @data)
|
146
|
+
rescue Exception => e
|
147
|
+
p "--Runtime error--"
|
148
|
+
p e
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
149
152
|
end
|
@@ -8,7 +8,7 @@ module TomosiaIcon8Crawl
|
|
8
8
|
option :destination
|
9
9
|
option :max
|
10
10
|
def crawl(keyword)
|
11
|
-
TomosiaIcon8Crawl::CrawlIcon8.crawl(keyword, options[:destination], options[:max]
|
11
|
+
TomosiaIcon8Crawl::CrawlIcon8.crawl(keyword, options[:destination], options[:max])
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module TomosiaIcon8Crawl
|
2
|
-
VERSION = "0.1.
|
3
|
-
end
|
1
|
+
module TomosiaIcon8Crawl
|
2
|
+
VERSION = "0.1.5"
|
3
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
require "tomosia_icon8_crawl"
|
3
|
-
|
4
|
-
RSpec.configure do |config|
|
5
|
-
|
6
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
7
|
-
config.run_all_when_everything_filtered = true
|
8
|
-
config.filter_run :focus
|
9
|
-
# Enable flags like --only-failures and --next-failure
|
10
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
11
|
-
|
12
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
13
|
-
config.disable_monkey_patching!
|
14
|
-
|
15
|
-
config.expect_with :rspec do |c|
|
16
|
-
c.syntax = :expect
|
17
|
-
end
|
18
|
-
end
|
1
|
+
require "bundler/setup"
|
2
|
+
require "tomosia_icon8_crawl"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
|
6
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
7
|
+
config.run_all_when_everything_filtered = true
|
8
|
+
config.filter_run :focus
|
9
|
+
# Enable flags like --only-failures and --next-failure
|
10
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
11
|
+
|
12
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
13
|
+
config.disable_monkey_patching!
|
14
|
+
|
15
|
+
config.expect_with :rspec do |c|
|
16
|
+
c.syntax = :expect
|
17
|
+
end
|
18
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
RSpec.describe TomosiaIcon8Crawl do
|
2
|
-
it "has a version number" do
|
3
|
-
expect(TomosiaIcon8Crawl::VERSION).not_to be nil
|
4
|
-
end
|
5
|
-
|
6
|
-
it "does something useful" do
|
7
|
-
expect(false).to eq(true)
|
8
|
-
end
|
9
|
-
end
|
1
|
+
RSpec.describe TomosiaIcon8Crawl do
|
2
|
+
it "has a version number" do
|
3
|
+
expect(TomosiaIcon8Crawl::VERSION).not_to be nil
|
4
|
+
end
|
5
|
+
|
6
|
+
it "does something useful" do
|
7
|
+
expect(false).to eq(true)
|
8
|
+
end
|
9
|
+
end
|
data/tomosia_icon8_crawl.gemspec
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
require_relative 'lib/tomosia_icon8_crawl/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = "tomosia_icon8_crawl"
|
5
|
-
spec.version = TomosiaIcon8Crawl::VERSION
|
6
|
-
spec.authors = ["ninh-tomosia"]
|
7
|
-
spec.email = ["tt.ninh.le@tomosia.com"]
|
8
|
-
|
9
|
-
spec.summary = %q{tomosia-icon8-crawl using download image from
|
10
|
-
spec.homepage = "https://github.com/ninh-tomosia/tomosia-icon8-crawl"
|
11
|
-
spec.license = "MIT"
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
-
|
14
|
-
spec.add_development_dependency "bundler"
|
15
|
-
spec.add_development_dependency "rake"
|
16
|
-
spec.add_runtime_dependency "thor"
|
17
|
-
spec.add_development_dependency "rspec"
|
18
|
-
spec.add_runtime_dependency "httparty"
|
19
|
-
spec.add_runtime_dependency "writeexcel"
|
20
|
-
spec.add_runtime_dependency "nokogiri"
|
21
|
-
spec.add_runtime_dependency "pry"
|
22
|
-
|
23
|
-
# Specify which files should be added to the gem when it is released.
|
24
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
-
|
26
|
-
spec.files = `git ls-files`.split("\n")
|
27
|
-
spec.bindir = "exe"
|
28
|
-
spec.executables = 'tomosia_icon8_crawl'
|
29
|
-
spec.require_paths = ["lib"]
|
1
|
+
require_relative 'lib/tomosia_icon8_crawl/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "tomosia_icon8_crawl"
|
5
|
+
spec.version = TomosiaIcon8Crawl::VERSION
|
6
|
+
spec.authors = ["ninh-tomosia"]
|
7
|
+
spec.email = ["tt.ninh.le@tomosia.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{tomosia-icon8-crawl using download image from icons8.com}
|
10
|
+
spec.homepage = "https://github.com/ninh-tomosia/tomosia-icon8-crawl"
|
11
|
+
spec.license = "MIT"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
|
14
|
+
spec.add_development_dependency "bundler"
|
15
|
+
spec.add_development_dependency "rake"
|
16
|
+
spec.add_runtime_dependency "thor"
|
17
|
+
spec.add_development_dependency "rspec"
|
18
|
+
spec.add_runtime_dependency "httparty"
|
19
|
+
spec.add_runtime_dependency "writeexcel"
|
20
|
+
spec.add_runtime_dependency "nokogiri"
|
21
|
+
spec.add_runtime_dependency "pry"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
|
26
|
+
spec.files = `git ls-files`.split("\n")
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = 'tomosia_icon8_crawl'
|
29
|
+
spec.require_paths = ["lib"]
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomosia_icon8_crawl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ninh-tomosia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -170,5 +170,5 @@ requirements: []
|
|
170
170
|
rubygems_version: 3.1.2
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
|
-
summary: tomosia-icon8-crawl using download image from
|
173
|
+
summary: tomosia-icon8-crawl using download image from icons8.com
|
174
174
|
test_files: []
|