ImageScraper 0.0.1 → 0.0.2
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/README.md +2 -2
- data/lib/ImageScraper.rb +18 -5
- data/lib/ImageScraper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2eb9f4c1f528a20ad935619c31aa22ad3a9600b
|
4
|
+
data.tar.gz: d902e11cbe227933eecdf81ccdf5399feaed49f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7448f2fb708916790b818d2974eeb8de961b72245b88e83248c91d19c4d5f61e02bda8a14f7cc75ec4e6edd7f2cf83c1275664ce29efc4f37260ed885067341
|
7
|
+
data.tar.gz: 0eb2ae8cff936e05a61a8b4a3298c1e02f67b92f47ade27fad3031180a0354c4eb78fb55dcb406a5cb7e7ada25a54cc18fc6288bb1c141920bc2c2787c354029
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ImageScraper
|
2
2
|
|
3
|
-
|
3
|
+
A gem which downloads all the images from a given url.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -24,7 +24,7 @@ TODO: Write usage instructions here
|
|
24
24
|
|
25
25
|
## Contributing
|
26
26
|
|
27
|
-
1. Fork it ( https://github.com/
|
27
|
+
1. Fork it ( https://github.com/sam09/ImageScraper/fork )
|
28
28
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
29
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
30
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/ImageScraper.rb
CHANGED
@@ -6,9 +6,6 @@ module ImageScraper
|
|
6
6
|
|
7
7
|
#The constructor
|
8
8
|
def self.initialize(url, folder = "Images")
|
9
|
-
if url[url.length] != "/"
|
10
|
-
url += "/"
|
11
|
-
end
|
12
9
|
@url = url
|
13
10
|
@folder = folder
|
14
11
|
end
|
@@ -18,11 +15,26 @@ module ImageScraper
|
|
18
15
|
@page = Nokogiri::HTML(open(@url).read)
|
19
16
|
end
|
20
17
|
|
21
|
-
|
18
|
+
|
19
|
+
def self.getNewUrl()
|
20
|
+
new_url = /([a-z0-9]|_)+.(html)|(php)$/.match(@url)
|
21
|
+
puts new_url.to_s
|
22
|
+
n = new_url.to_s
|
23
|
+
return @url.slice! n
|
24
|
+
end
|
25
|
+
|
26
|
+
#A method to get image links
|
22
27
|
def self.getImgLinks()
|
23
28
|
img = @page.css('img')
|
24
29
|
@imgLinks = Array.new
|
25
30
|
|
31
|
+
new_url = self.getNewUrl()
|
32
|
+
|
33
|
+
if @url[@url.length-1] != '/'
|
34
|
+
@url += "/"
|
35
|
+
end
|
36
|
+
print new_url
|
37
|
+
|
26
38
|
img.each do |i|
|
27
39
|
@imgLinks.push(@url+i["src"])
|
28
40
|
end
|
@@ -57,8 +69,9 @@ module ImageScraper
|
|
57
69
|
end
|
58
70
|
|
59
71
|
#A method to download all files at a given url
|
60
|
-
def self.
|
72
|
+
def self.Scrap()
|
61
73
|
self.getPage
|
74
|
+
puts "Page Found"
|
62
75
|
self.getImgNames
|
63
76
|
self.getImgLinks
|
64
77
|
self.download
|
data/lib/ImageScraper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ImageScraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Radhakrishnan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|