simple-news-crawler 1.0.1 → 1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sn_crawler.rb +8 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 989f5fa8ff63672a63845c07ac225ff46ecf7786
4
- data.tar.gz: 4c47b180951f0741d4c4a0abc131677a19054b83
3
+ metadata.gz: 24fbc21d296bb28b773bb2fb6d2f955a73b67c4c
4
+ data.tar.gz: 09ddb5446af9e6b2b3a2961f9c897b02f81f0c95
5
5
  SHA512:
6
- metadata.gz: 1654a851eaccbc671176151ac137a9ca0ada40e96d6edc41f2f7404a5328111fb5530424f6f9dd83e93127c36e84b873b4aa971f23ab3f67084d3fd3a87158f9
7
- data.tar.gz: 1a2a58e2b2393b2c7f36710703e090d0c8ab9d439d16019f44a4e234451c55a647f14de47a2179c6dad503cd1f1edd7f03979257ed583fffda6f2ecf63c304e7
6
+ metadata.gz: 905f48fe28a797e4b375aa101ab42ff15c119c14d25356e5f4ebbe5b32d0b0fdf2b60659fa07f22e6ad6ac36442dbc2d9a3b80ed158a9dbd54cdf898df352e4f
7
+ data.tar.gz: 4dd94b7507d88c73fde7705f592623a65116f1ffd037d5774eea51b8d78beb8d80ba5358360b00ed25177ba338a3a262ad732435d0d04b713e9fd014097419b0
data/lib/sn_crawler.rb CHANGED
@@ -74,7 +74,7 @@ class SNCrawler
74
74
  page.links_with(:href => /\.(rss|xml)/).each do |link|
75
75
  src = ""
76
76
  if !link.href.include? "http"
77
- src = URI.parse(source).host + link.href
77
+ src = URI.parse(@source).host + link.href
78
78
  else
79
79
  src = link.href
80
80
  end
@@ -126,16 +126,19 @@ class SNCrawler
126
126
  request = Curl.get(u.to_s)
127
127
  begin
128
128
  source = XML::Parser.string(request.body_str)
129
- content = source.parse
129
+ root_content = source.parse
130
130
  ## Find all channels
131
- channels = content.root.find(channel_path)
131
+ channels = root_content.root.find(channel_path)
132
132
  ## For each channel processing the data
133
133
  channels.each do |c|
134
- lang = c.find_first('language').content
135
- if lang.nil? then
134
+ lang_field = c.find_first('language')
135
+ if lang_field.nil? then
136
136
  lang = "en_US"
137
+ else
138
+ lang = lang_field.content.to_s
137
139
  end
138
140
  items = c.find(item_tag)
141
+ puts item_tag
139
142
  items.each do |i|
140
143
  title = i.find_first(title_tag).content
141
144
  title = title.gsub("'","")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-news-crawler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nguyen Anh Tuan