taiwanese_news_parser 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +23 -0
- data/Rakefile +4 -0
- data/g0v.json +37 -0
- data/lib/taiwanese_news_parser/parser/apple_daily.rb +69 -0
- data/lib/taiwanese_news_parser/parser/china_times.rb +76 -0
- data/lib/taiwanese_news_parser/parser/cna.rb +59 -0
- data/lib/taiwanese_news_parser/parser/cts.rb +52 -0
- data/lib/taiwanese_news_parser/parser/ettoday.rb +53 -0
- data/lib/taiwanese_news_parser/parser/liberty_times.rb +66 -0
- data/lib/taiwanese_news_parser/parser/liberty_times_big5.rb +51 -0
- data/lib/taiwanese_news_parser/parser/now_news.rb +53 -0
- data/lib/taiwanese_news_parser/parser/tvbs.rb +46 -0
- data/lib/taiwanese_news_parser/parser/udn.rb +43 -0
- data/lib/taiwanese_news_parser/parser.rb +57 -0
- data/lib/taiwanese_news_parser/url_cleaner.rb +19 -0
- data/lib/taiwanese_news_parser/version.rb +3 -0
- data/lib/taiwanese_news_parser.rb +15 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/taiwanese_news_parser/parser/apple_daily_s1.html +484 -0
- data/spec/taiwanese_news_parser/parser/apple_daily_s2.html +333 -0
- data/spec/taiwanese_news_parser/parser/apple_daily_s3.html +334 -0
- data/spec/taiwanese_news_parser/parser/apple_daily_spec.rb +57 -0
- data/spec/taiwanese_news_parser/parser/china_times_s1.html +513 -0
- data/spec/taiwanese_news_parser/parser/china_times_s2.html +538 -0
- data/spec/taiwanese_news_parser/parser/china_times_s3.html +893 -0
- data/spec/taiwanese_news_parser/parser/china_times_s4.html +1045 -0
- data/spec/taiwanese_news_parser/parser/china_times_spec.rb +63 -0
- data/spec/taiwanese_news_parser/parser/cna_s1.html +1616 -0
- data/spec/taiwanese_news_parser/parser/cna_spec.rb +33 -0
- data/spec/taiwanese_news_parser/parser/cts_s1.html +672 -0
- data/spec/taiwanese_news_parser/parser/cts_s2.html +672 -0
- data/spec/taiwanese_news_parser/parser/cts_spec.rb +36 -0
- data/spec/taiwanese_news_parser/parser/ettoday_s1.html +1817 -0
- data/spec/taiwanese_news_parser/parser/ettoday_s2.html +1822 -0
- data/spec/taiwanese_news_parser/parser/ettoday_spec.rb +35 -0
- data/spec/taiwanese_news_parser/parser/liberty_times_big5_s1.html +213 -0
- data/spec/taiwanese_news_parser/parser/liberty_times_big5_spec.rb +31 -0
- data/spec/taiwanese_news_parser/parser/liberty_times_s1.html +145 -0
- data/spec/taiwanese_news_parser/parser/liberty_times_spec.rb +29 -0
- data/spec/taiwanese_news_parser/parser/now_news_s1.html +968 -0
- data/spec/taiwanese_news_parser/parser/now_news_s2.html +986 -0
- data/spec/taiwanese_news_parser/parser/now_news_spec.rb +31 -0
- data/spec/taiwanese_news_parser/parser/tvbs_s1.html +734 -0
- data/spec/taiwanese_news_parser/parser/tvbs_s2.html +739 -0
- data/spec/taiwanese_news_parser/parser/tvbs_spec.rb +36 -0
- data/spec/taiwanese_news_parser/parser/udn_s1.html +1678 -0
- data/spec/taiwanese_news_parser/parser/udn_spec.rb +42 -0
- data/taiwanese_news_parser.gemspec +30 -0
- metadata +237 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TaiwaneseNewsParser::Parser::NowNews do
|
4
|
+
describe '#parse' do
|
5
|
+
it do
|
6
|
+
url = 'http://www.nownews.com/n/2014/03/21/1159861'
|
7
|
+
FakeWeb.register_uri(:get, url, body:sample(__FILE__,'now_news_s1.html'))
|
8
|
+
article = described_class.new(url).parse
|
9
|
+
article[:title].should == '軍警強攻立院傳聞四起 總統府:不可能!'
|
10
|
+
article[:content].should include('青年占領立法院反服貿活動持續進行,學生代表林飛帆21日晚間召開記者會表示')
|
11
|
+
article[:content].should include('但採取激烈的方式,社會各界均不樂見。')
|
12
|
+
article[:company_name].should == 'NowNews'
|
13
|
+
article[:reporter_name].should == '王鼎鈞'
|
14
|
+
article[:published_at].should == Time.new(2014,3,21,20,36)
|
15
|
+
end
|
16
|
+
it do
|
17
|
+
url = 'http://www.nownews.com/n/2014/03/20/1156607'
|
18
|
+
FakeWeb.register_uri(:get, url, body:sample(__FILE__,'now_news_s2.html'))
|
19
|
+
article = described_class.new(url).parse
|
20
|
+
article[:title].should == '劉興武跳脫傳統經營 金漢柿餅園區轉型觀光休閒'
|
21
|
+
article[:content].should include('新埔鎮旱坑里金漢柿餅產業文化園區由劉金漢於民國三十六年始創')
|
22
|
+
article[:reporter_name].should == '房書勤'
|
23
|
+
article[:published_at].should == Time.new(2014,3,20,0,43)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
describe '.parse_url_id' do
|
27
|
+
it do
|
28
|
+
described_class.parse_url_id('http://www.nownews.com/n/2014/03/21/1159861').should == '1159861'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|