taiwanese_news_parser 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2dcc61f33b26dccfd916bb3cba7d237e8ab9800
4
- data.tar.gz: 766787ce1574e678f115c66501294aed32020c7d
3
+ metadata.gz: 79a3f654d113a687f130e3c3f2f93b17bee188a2
4
+ data.tar.gz: 0dc2e3788a102d567895c931e6f4be865176c2af
5
5
  SHA512:
6
- metadata.gz: 68676325f905bd14dae2ce14bc306f9a2ff5c81fbac6627b1d4e4d0b2f1b1f097652ac15b37e4b1b25844a626a961888680906898c66ed2e999c1a07cb2c283e
7
- data.tar.gz: 2ee0be9d077f3007fcf2cf23cd18acc72ed737659d74bc3ecbda1dc701176391ab55f0b68eb74c3956188d9d31684fe132ace9ff1b09547d3f80c817153978e8
6
+ metadata.gz: a77e312c03afe9abf724a53a1685d6ddac30a9353d9d9d4414c7a8a93cadc15b597829b6ede0134d936c54eb8216aee4568ee34fbb71c52b6fac1f507c9a7987
7
+ data.tar.gz: e3695d63bd62162c6909bfbfa646850f1bf1b6ef8f889029e69a09819faa4d4e35723550956f456adaca73c0d886fcbcea629f29896049726131f1b9c792cab1
@@ -23,14 +23,13 @@ class TaiwaneseNewsParser::Parser::LibertyTimesNews < TaiwaneseNewsParser::Parse
23
23
  @article[:company_name] = parse_company_name
24
24
  @article[:content] = doc.css('#newstext p').text
25
25
 
26
- time = doc.at_css('#newstext span').text[%r{\d{4}-\d{1,2}-\d{1,2}\W*\d{2}:\d{2}}]
27
- if time.nil?
28
- match = doc.at_css('#newstext span').text.match(%r{(\d{2}):(\d{2})})
29
- now = Time.now
30
- today = Date.today
31
- @article[:published_at] = Time.new(today.year, today.month, today.day, match[1].to_i, match[2].to_i)
32
- else
33
- @article[:published_at] = Time.parse("#{time}:00")
26
+ doc.css('script').each do |script|
27
+ match = script.content.match(%r{newsTime\s=\s\'(\d+)\';$})
28
+ if not match.nil?
29
+ timestamp = match.captures[0].to_i
30
+ @article[:published_at] = Time.at(timestamp)
31
+ break
32
+ end
34
33
  end
35
34
 
36
35
  @article[:reporter_name] = parse_reporter_name()
@@ -1,3 +1,3 @@
1
1
  module TaiwaneseNewsParser
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -14,7 +14,7 @@ describe TaiwaneseNewsParser::Parser::LibertyTimesNews do
14
14
  article[:content].should include('在今年的七合一選舉和來年的立委、總統選舉時,要求候選人承諾促成非核家園。')
15
15
  article[:company_name].should == '自由時報'
16
16
  article[:reporter_name].should == '李欣芳'
17
- article[:published_at].should == Time.new(2014,4,30,14,49)
17
+ article[:published_at].should == Time.new(2014,4,30,14,49,37)
18
18
  end
19
19
  it do
20
20
  url = 'http://news.ltn.com.tw/news/world/breakingnews/997893'
@@ -24,7 +24,7 @@ describe TaiwaneseNewsParser::Parser::LibertyTimesNews do
24
24
  article[:content].should include('紐約知名的薩克斯百貨公司')
25
25
  article[:company_name].should == '自由時報'
26
26
  article[:reporter_name].should == nil
27
- article[:published_at].should == Time.new(2014,4,30,10,57)
27
+ article[:published_at].should == Time.new(2014,4,30,10,57,57)
28
28
  end
29
29
 
30
30
  it do
@@ -35,7 +35,7 @@ describe TaiwaneseNewsParser::Parser::LibertyTimesNews do
35
35
  article[:content].should include('又傳酒駕釀禍!花蓮縣壽豐鄉一名男子昨天(28日)在友人家喝得爛醉')
36
36
  article[:company_name].should == '自由時報'
37
37
  article[:reporter_name].should == nil
38
- article[:published_at].should == Time.new(2013,6,29,17,52)
38
+ article[:published_at].should == Time.new(2013,6,29,17,52,5)
39
39
  end
40
40
  end
41
41
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taiwanese_news_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - lulalala
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-04 00:00:00.000000000 Z
11
+ date: 2014-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler