bnext_robot 0.1.0 → 0.1.1
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/bin/bnext_robot +21 -5
- data/bnext_robot.gemspec +4 -3
- data/lib/ext_class/bnext_robot.rb +6 -6
- data/lib/ext_class/bnext_version.rb +5 -0
- data/spec/class_spec/bnext_robot_spec.rb +51 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4d6434150f83681483b2268561f90732ee0af59
|
4
|
+
data.tar.gz: 5380737e44b6ac59b6f01d07bdb982092e73eff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28fe216b63af594e6fa914f2fe68b7d1a6713afd0a3b40728884dd09bab1e9533a822022f802381ac2993ceb060f4dd3822dc4ba144fbf4739cb8a358942ff2a
|
7
|
+
data.tar.gz: 66b84133a7064408f2e4a2f1741cd22510a157215f3d8af808f580c2838f4e2c841c27b728d4a9ad6c6529792aaeda4ad82a0e68e396b8d2a3e94fa8562bcbaa
|
data/bin/bnext_robot
CHANGED
@@ -1,15 +1,31 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require_relative '../lib/ext_class/bnext_robot'
|
3
3
|
|
4
|
-
fail ArgumentError, "Usage: bnext_robot [
|
4
|
+
fail ArgumentError, "Usage: bnext_robot [weekrank/dayrank/feed]\n" if ARGV.count == 0
|
5
5
|
|
6
6
|
bnext_robot = BNextRobot.new
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
function = ARGV[0]
|
9
|
+
|
10
|
+
case function
|
11
|
+
when 'weekrank'
|
10
12
|
bnext_robot.show_week_rank
|
11
|
-
|
13
|
+
when 'dayrank'
|
12
14
|
bnext_robot.show_day_rank
|
15
|
+
when 'feed'
|
16
|
+
puts 'Category list:'
|
17
|
+
puts '[網路]: internet [科技]: tech [行銷]: marketing'
|
18
|
+
puts '[創業]: startup [人物]: people [技能]: skill'
|
19
|
+
print 'Category: '
|
20
|
+
cat = $stdin.readline.chomp
|
21
|
+
print 'Page number: '
|
22
|
+
page_no = $stdin.readline.chomp
|
23
|
+
feed_found = bnext_robot.get_feeds(cat, page_no)
|
24
|
+
if feed_found.length == 0
|
25
|
+
puts 'Error: No result found. Check the input or internet connection.'
|
26
|
+
else
|
27
|
+
puts "#{feed_found}"
|
28
|
+
end
|
13
29
|
else
|
14
|
-
puts "Please
|
30
|
+
puts "Error: Please insert 'weekrank','dayrank', or 'feed'."
|
15
31
|
end
|
data/bnext_robot.gemspec
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
$LOAD_PATH.push File.expand_path('../
|
1
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'ext_class/bnext_version'
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
4
5
|
s.name = 'bnext_robot'
|
5
|
-
s.version =
|
6
|
-
s.date =
|
6
|
+
s.version = BnextRobot::VERSION
|
7
|
+
s.date = BnextRobot::DATE
|
7
8
|
s.executables << 'bnext_robot'
|
8
9
|
s.summary = 'Web scrapy for Business Next'
|
9
10
|
s.description = 'Web scrapy for Business Next, including showing day/week rank and feeds extraction'
|
@@ -85,12 +85,12 @@ class BNextRobot
|
|
85
85
|
def _extract_feed(feed_id)
|
86
86
|
query_url = @domain[0..-2] + "#{feed_id}"
|
87
87
|
document = Oga.parse_html(open(query_url))
|
88
|
-
title = document.xpath(TITLE_XPATH).text
|
89
|
-
author = document.xpath(INFO_XPATH)[0].text.gsub('撰文者:'.force_encoding('ascii-8bit'), '')
|
90
|
-
date = document.xpath(INFO_XPATH)[1].text.gsub('發表日期:'.force_encoding('ascii-8bit'), '')
|
91
|
-
content = document.xpath(CONTENT_XPATH).text
|
92
|
-
tags = document.xpath(TAG_XPATH).map(
|
88
|
+
title = document.xpath(TITLE_XPATH).text.force_encoding('utf-8')
|
89
|
+
author = document.xpath(INFO_XPATH)[0].text.gsub('撰文者:'.force_encoding('ascii-8bit'), '').force_encoding('utf-8')
|
90
|
+
date = document.xpath(INFO_XPATH)[1].text.gsub('發表日期:'.force_encoding('ascii-8bit'), '').force_encoding('utf-8')
|
91
|
+
content = document.xpath(CONTENT_XPATH).text.force_encoding('utf-8')
|
92
|
+
tags = document.xpath(TAG_XPATH).map{ |i| i.text.force_encoding('utf-8') }
|
93
93
|
imgs = document.xpath(IMGS_XPATH).map(&:text)
|
94
|
-
Feed.new(title, author, date, tags, query_url, content, imgs)
|
94
|
+
Feed.new(title, author, date, tags, query_url, content, imgs).to_hash()
|
95
95
|
end
|
96
96
|
end
|
@@ -26,6 +26,52 @@ week_rank = [
|
|
26
26
|
"消費者眼球都在哪?世界即時通訊及社群媒體使用情形分析: http://www.bnext.com.tw/article/view/id/37667"
|
27
27
|
]
|
28
28
|
|
29
|
+
first_feed = {
|
30
|
+
"title"=>"管中閔談數位時代的政策形成:「自己的國家自己救,自己的政策自己修」",
|
31
|
+
"author"=>"James Huang",
|
32
|
+
"date"=>"2015/10/18",
|
33
|
+
"tags"=>["TEDxTAIPEI", "管中閔", "群眾智慧", "政府公開資料", "TEDxTAIPEI Big Bang", "vTaiwan", "資訊公開"],
|
34
|
+
"link"=>"http://www.bnext.com.tw/article/view/id/37693",
|
35
|
+
"content"=>"\r
|
36
|
+
TED X Taipei 2015 今日上午展開第二天的議程:「群」。「群」從談數位時代的公民教育作為開場,談人的選擇如何驅動了社會、談網路如何翻轉媒體、談群眾參與的力量將如何驅動社會價值觀,但可能也如何有限。
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
下台後在臉書上遠比在台上時活躍,也擁有巨大網民人氣,人稱管爺的前經建會、改制後的國發會主委管中閔首先詢問觀眾,許多文章談蔣經國,回憶那個時代的美好,但我們最該問問為什麼今天沒有尹仲容、李國鼎、孫運璿?
|
41
|
+
|
42
|
+
尹仲容曾經掌管二戰後的台灣經濟,但已經過世超過 50 年,李國鼎、孫運璿在政府財經、科技相關工作都超過 8 年以上,分別帶領台灣經濟成長與經濟轉型,重要政策曾經包含有成立加工出口區、產業的二次替代與成立科學園區發展半導體產業等形成台灣今日產業面貌的重要經濟決策。管中閔觀察,過去人民因為資訊傳播速度與品質有限,社會非常仰賴菁英的決策,政府政策有賴高層菁英的策略思考來推動,因此政策的推動通常由行政機關的高層告訴你要怎麼做來決定,進一步推往立法機關,並透過公聽會、工會、公會代表、立法院委員會的參與來宣導與溝通。
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
但網際網路所帶來的資訊開放與效率,可能打破了這種政策決策形成過程,「家父長式的政策決議」已經無法說服一般人民。管中閔以自己任內推動,最後宣告失敗的「自由經濟示範區」政策為例,說明政府目前政策決策形成過程的巨大困境。政府目前多數的政策決策方式,還是依賴行政部門高層的思考,發給行政部門的基層或周遭的智庫組織形成政策建議,透過傳統媒體與電子媒體的訪問或說明、立法院的委員會、公聽會、工會、產業公會、地方政府的說明會等等來增加民眾的參與與溝通。但根據管中閔自己參加這樣的溝通過程,發現這樣的過程時間成本高昂,但效果卻很容易不彰。這些不彰的過程,其實正是經濟學裡典型的「資訊斷裂」、「資訊壟斷」與「代理人問題」。
|
47
|
+
|
48
|
+
|
49
|
+
(圖說:傳統政策決策過程的問題,管中閔提供)
|
50
|
+
|
51
|
+
管中閔觀察共享經濟中創新模式的特點,發現網際網路平台所帶來的資訊公開、分享而不壟斷的群眾外包,其媒合效率可能可以比以往驚人,透過網際網路的效力,資訊公開與群眾智慧來形成政府政策的決策模式比以往都更加有機會。管中閔以同在現場,並目前還正在台灣行政部門內閣裡的蔡玉玲政務委員,其所推動群眾參與政策形成過程的 vTaiwan平台為例,發現透過網路讓群眾參與政策討論,溝通效率與效果可能遠比以往菁英政策決策模式的效果還好。透過網路平台開放政策討論,首先讓行政部門在政策形成的過程有機會直接快速的與立法部門溝通,包含行政部門、立法部門、人民與智庫都可以作為政策的提案者,也都同時可以作為政策決策所需要的資料提供者,這樣的過程有助於政策決策時的利益相關人直接溝通並互相理解,也可以加快傳統家父長式菁英政策決策過程的不足。
|
52
|
+
|
53
|
+
|
54
|
+
(圖說:透過個人的政治實踐,發現政策形成過程溝通效率的不足,管中閔提供)
|
55
|
+
|
56
|
+
管中閔分享,在 2014 年 3 月,當立法院衝進許多學生,最後演變成學運的同時,他其實非常深刻在反省,行政部門裡面包含他自己有這麼多好人,這麼努力地想要讓國家讓社會更好,為什麼我們做的事情會被指責到那麼不堪。當他看到「自己的國家自己救」還包含有 fxxx goverment 的這句標語時他非常震驚,後來自由貿易區法案的推動過程,他實踐了自己的假設,花了許多時間上媒體宣傳、同時參加公聽會、立法院委員會、產業公會說明會等等,最後推論也許不只是政策形成的「溝通不夠」而已,可能還有政策形成的「群眾參與」之不足。
|
57
|
+
|
58
|
+
|
59
|
+
(圖說:vTaiwan 平台目前的討論首頁,數位時代翻攝)
|
60
|
+
|
61
|
+
管中閔最後回答主持人許毓仁對於演講的前一天,國民黨剛針對 2016 總統大選提名「柱下朱上」的決定,他表示他很認真在思考明年總統大選是否要去投票,目前也還沒有明白的答案,
|
62
|
+
|
63
|
+
|
64
|
+
但他對於未來政治的思考,已經從「自己的國家自己救」,推往公民社會透過網路直接群眾參與,更進一步的「自己的政策自己修」。
|
65
|
+
|
66
|
+
|
67
|
+
管中閔相信,這樣大家才能一起讓國家與社會更好。
|
68
|
+
|
69
|
+
|
70
|
+
(圖說:透過網路平台資訊公開與群眾智慧,有機會增加政策形成溝通的媒合效率。管中閔提供)
|
71
|
+
\r
|
72
|
+
",
|
73
|
+
"imgs"=>["https://3.bp.blogspot.com/-UZcqMQoahf4/ViNhwPcsLmI/AAAAAAABVGA/tI6Ow_MfMIw/s600/2015-10-18+11.21.32.jpg", "https://3.bp.blogspot.com/-6UCC-xoSxwg/ViNkbahpmZI/AAAAAAABVGY/_g1epWBn3-M/s600/2015-10-18+11.21.35.jpg", "https://3.bp.blogspot.com/-S2GsRv23HeQ/ViNnaF0WQJI/AAAAAAABVHY/X6ZR-EyOiTE/s600/%25E8%259E%25A2%25E5%25B9%2595%25E6%2588%25AA%25E5%259C%2596+2015-10-18+17.28.08.png", "https://3.bp.blogspot.com/-nsgyXfU02U0/ViNopfEvxBI/AAAAAAABVIE/zf8eXkxrc80/s600/%25E8%259E%25A2%25E5%25B9%2595%25E6%2588%25AA%25E5%259C%2596+2015-10-18+17.37.59.png", "https://3.bp.blogspot.com/-UjCZPIDQyEU/ViNnAjk9oRI/AAAAAAABVHE/1boW7YmJh38/s600/%25E8%259E%25A2%25E5%25B9%2595%25E6%2588%25AA%25E5%259C%2596+2015-10-18+17.22.27.png", "https://3.bp.blogspot.com/-gNv9kCtyHlQ/ViNn3Q8kpCI/AAAAAAABVHs/3DOzuDCeR2o/s600/%25E8%259E%25A2%25E5%25B9%2595%25E6%2588%25AA%25E5%259C%2596+2015-10-18+17.32.34.png"]
|
74
|
+
}
|
29
75
|
VCR.configure do |config|
|
30
76
|
config.cassette_library_dir = './spec/testfiles/vcr_cassettes'
|
31
77
|
config.hook_into :webmock
|
@@ -63,10 +109,15 @@ end
|
|
63
109
|
|
64
110
|
VCR.use_cassette('bnext_techpage') do
|
65
111
|
bnext_tech = bnext_robot.get_feeds("tech", 1)
|
112
|
+
|
66
113
|
describe "Get correct list of each category" do
|
67
114
|
|
68
115
|
it 'get right number of feeds' do
|
69
116
|
bnext_tech.size.must_equal 20
|
70
117
|
end
|
118
|
+
|
119
|
+
it 'get right feed' do
|
120
|
+
bnext_tech[0].to_hash.must_equal first_feed
|
121
|
+
end
|
71
122
|
end
|
72
123
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bnext_robot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacky Pan
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-10-
|
14
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: minitest
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- bin/bnext_robot
|
102
102
|
- bnext_robot.gemspec
|
103
103
|
- lib/ext_class/bnext_robot.rb
|
104
|
+
- lib/ext_class/bnext_version.rb
|
104
105
|
- lib/int_class/feed.rb
|
105
106
|
- lib/int_class/filter_condition.rb
|
106
107
|
- lib/int_module/crawl_runner.rb
|