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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 866a2fcd819cf4ff9b2a06a9ee13b20711e744f7
4
- data.tar.gz: fbd3c343317c8815078f2a7e99ae475a140516a2
3
+ metadata.gz: a2eb9f4c1f528a20ad935619c31aa22ad3a9600b
4
+ data.tar.gz: d902e11cbe227933eecdf81ccdf5399feaed49f7
5
5
  SHA512:
6
- metadata.gz: afac396c28c14412328363f571f236a8f1e143cfcb9a6dcc93272a103ee82d232efe08876510fc1ff2783ecd59960bb52b4a9390a1c1395dc069a00c0244a7d5
7
- data.tar.gz: d7403a3cf5686ea609bd3e96f541a5c5a305c1da5696d6af7e02985de66aa734b147f008f393310b6e5b4c266ef32519c4bb01d4a4e040f945de119265e45f19
6
+ metadata.gz: a7448f2fb708916790b818d2974eeb8de961b72245b88e83248c91d19c4d5f61e02bda8a14f7cc75ec4e6edd7f2cf83c1275664ce29efc4f37260ed885067341
7
+ data.tar.gz: 0eb2ae8cff936e05a61a8b4a3298c1e02f67b92f47ade27fad3031180a0354c4eb78fb55dcb406a5cb7e7ada25a54cc18fc6288bb1c141920bc2c2787c354029
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ImageScraper
2
2
 
3
- TODO: Write a gem description
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/[my-github-username]/ImageScraper/fork )
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
- #a method to get image links
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.Scrape()
72
+ def self.Scrap()
61
73
  self.getPage
74
+ puts "Page Found"
62
75
  self.getImgNames
63
76
  self.getImgLinks
64
77
  self.download
@@ -1,3 +1,3 @@
1
1
  module ImageScraper
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-19 00:00:00.000000000 Z
11
+ date: 2015-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler