bnext_robot 0.1.5 → 0.1.6
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/.gitignore +36 -0
- data/.travis.yml +11 -0
- data/README.md +128 -0
- data/lib/ext_class/bnext_robot.rb +32 -6
- data/lib/ext_class/bnext_version.rb +2 -2
- metadata +4 -3
- data/Gemfile.lock +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c37fd1b8f8a5b0fe9e9bb11c52c14ef7cb0e959d
|
4
|
+
data.tar.gz: 5a1048254cd2052ce53768f5b98094e1bed0c0c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f7b08a611678b5bc1841194d922e36c429a7f26ba17e9f16f08b7b87dc31ae591750ecfd495bb2802df244ae888b0e57c874f929fff4637e8383debeef7a4d0
|
7
|
+
data.tar.gz: ad4602ca7e061c1ca974da750b2776098eab347e0d21a1adc12c089840cf6e28f872bc5c941415b20a10ea96ad83af2efdd04dce90a906f6688fb581857ab163
|
data/.gitignore
CHANGED
@@ -1,2 +1,38 @@
|
|
1
|
+
# Mac DS_Store
|
2
|
+
.DS_Store
|
3
|
+
|
1
4
|
*.gem
|
5
|
+
*.rbc
|
6
|
+
/.config
|
7
|
+
/coverage/
|
8
|
+
/InstalledFiles
|
9
|
+
/pkg/
|
10
|
+
/spec/reports/
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
|
15
|
+
## Specific to RubyMotion:
|
16
|
+
.dat*
|
17
|
+
.repl_history
|
18
|
+
build/
|
19
|
+
|
20
|
+
## Documentation cache and generated files:
|
21
|
+
/.yardoc/
|
22
|
+
/_yardoc/
|
23
|
+
/doc/
|
24
|
+
/rdoc/
|
25
|
+
|
26
|
+
## Environment normalisation:
|
27
|
+
/.bundle/
|
28
|
+
/vendor/bundle
|
29
|
+
/lib/bundler/man/
|
30
|
+
|
31
|
+
# for a library or gem, you might want to ignore these files since the code is
|
32
|
+
# intended to run in multiple environments; otherwise, check them in:
|
2
33
|
Gemfile.lock
|
34
|
+
.ruby-version
|
35
|
+
.ruby-gemset
|
36
|
+
|
37
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
38
|
+
.rvmrc
|
data/.travis.yml
ADDED
data/README.md
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# Business Next Scraper [](https://badge.fury.io/rb/bnext_robot) [](https://travis-ci.org/SOA-Upstart4/Team-HW-1-Ideate-and-Scrape)
|
2
|
+
##Overview
|
3
|
+
This is a scraper that collects articles and article-related information from the website
|
4
|
+
[Business Next](http://www.bnext.com.tw/).
|
5
|
+
|
6
|
+
* `show_day_rank` : show the top ranked articles within one day.
|
7
|
+
* `show_week_rank` : show the top ranked articles within one week.
|
8
|
+
* `get_feeds` : get feeds with a specific category and a specific page no.
|
9
|
+
|
10
|
+
##Repository structure
|
11
|
+
```
|
12
|
+
├── README.md
|
13
|
+
├── init_lib_struct.py
|
14
|
+
└── robot
|
15
|
+
├── Gemfile
|
16
|
+
├── Gemfile.lock
|
17
|
+
├── Rakefile
|
18
|
+
├── bin
|
19
|
+
│ └── bnext_robot
|
20
|
+
├── bnext_robot.gemspec
|
21
|
+
├── lib
|
22
|
+
│ ├── ext_class
|
23
|
+
│ │ └── bnext_robot.rb
|
24
|
+
│ ├── int_class
|
25
|
+
│ │ ├── feed.rb
|
26
|
+
│ │ └── filter_condition.rb
|
27
|
+
│ └── int_module
|
28
|
+
│ ├── crawl_runner.rb
|
29
|
+
│ └── feeds_filter.rb
|
30
|
+
└── spec
|
31
|
+
├── class_spec
|
32
|
+
│ └── bnext_robot_spec.rb
|
33
|
+
└── testfiles
|
34
|
+
└── vcr_cassettes
|
35
|
+
├── bnext_mainpage.yml
|
36
|
+
└── bnext_techpage.yml
|
37
|
+
```
|
38
|
+
##Usage of scraper
|
39
|
+
Install it with the following command:
|
40
|
+
|
41
|
+
```
|
42
|
+
$ gem install bnext_robot
|
43
|
+
```
|
44
|
+
|
45
|
+
Or else put it in your Gemfile as:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
gem bnext_robot
|
49
|
+
```
|
50
|
+
|
51
|
+
###1. Call the class methods
|
52
|
+
* Show the week ranking of articles.
|
53
|
+
|
54
|
+
```bash
|
55
|
+
$ bnext_robot weekrank
|
56
|
+
```
|
57
|
+
|
58
|
+
* Show the day ranking of articles.
|
59
|
+
|
60
|
+
```shell
|
61
|
+
$ bnext_robot dayrank
|
62
|
+
```
|
63
|
+
* Get feeds by selecting categories and page number.
|
64
|
+
|
65
|
+
```shell
|
66
|
+
$ bnext_robot feed
|
67
|
+
```
|
68
|
+
|
69
|
+
|
70
|
+
### ※ Sample results of show\_day\_rank
|
71
|
+
|
72
|
+
```
|
73
|
+
專業,就是用對方聽得懂的話,去告訴他不懂的事情: http://www.bnext.com.tw/article/view/id/37573
|
74
|
+
Surface名氣愈來愈旺!微軟趁勝追擊推出首款自家筆電Surface Book: http://www.bnext.com.tw/article/view/id/37578
|
75
|
+
蘋果iPhone在美市佔續增,Android陣營當心: http://www.bnext.com.tw/article/view/id/37581
|
76
|
+
打入Tesla 生態圈,網路第一代創業家賀元再現江湖 !: http://www.bnext.com.tw/article/view/id/37580
|
77
|
+
棉花糖系統開放更新!Now on Tap秘密武器正式出關!: http://www.bnext.com.tw/article/view/id/37568
|
78
|
+
Evernote的啟示:少了這個前提,商業計畫再完美也沒用!: http://www.bnext.com.tw/ext_rss/view/id/985113
|
79
|
+
賈伯斯去世4年了!為了紀念他,庫克寫了封email給員工: http://www.bnext.com.tw/ext_rss/view/id/988425
|
80
|
+
你真的知道Retina是什麼嗎?那些蘋果創造出來的技術名詞,你知道多少?: http://www.bnext.com.tw/ext_rss/view/id/985760
|
81
|
+
```
|
82
|
+
### ※ Sample results of get_feeds
|
83
|
+
**Get feeds with the structral format**
|
84
|
+
|
85
|
+
Note that each element in the array is a `Feed` object, every `Feed` object has several attributes, including:
|
86
|
+
|
87
|
+
- `title`: the title of the article
|
88
|
+
- `author`: the author of the article
|
89
|
+
- `date`: the posted date of the article
|
90
|
+
- `content`: the whole content the article contains
|
91
|
+
- `tags`: the tags tagged inside the article to be searched
|
92
|
+
- `imgs`: all images urls embedded inside the article
|
93
|
+
|
94
|
+
```
|
95
|
+
[{
|
96
|
+
:title=>"向網路新金融升級!阿里集團螞蟻金服啟動互聯網推進器計畫",
|
97
|
+
:author=>"許文貞",
|
98
|
+
:date=>"2015/10/16",
|
99
|
+
:content=>"\r\n 2014年10月16日才正式從中國阿里巴巴集團獨立出來的「螞蟻金服」,包含阿里巴巴過去知名的支付寶、餘額寶等各項金融業務,在成立滿一週歲的今(16)日,正式公開奠基於阿里雲之上的「螞蟻金融雲」服務及其下30種金融產品。螞蟻金服集團總裁井賢棟表示,「金融雲」所提供的雲端計算能力將成為新的基礎設施。此外,螞蟻金服也於昨日宣布投資中國的創業生態服務平台「36氪」,未來將合作打造中國最大的私募股權投資平台,投資金額外傳為1.5億美金。\n\n\n(圖說:成立滿一週年的螞蟻金服,在今日推出「螞蟻金融雲」的30種金融產品,未來除了自營金融商品,也將提供平台化的金融技術服務。圖片來源:許文貞攝影。)\n\n井賢棟在今日的螞蟻金服分享日活動中表示,中國必須要接受兩個新的經濟趨勢,一是經濟趨緩的新常態,二是「互聯網+」帶來的力量,讓傳統經濟轉變為新經濟,而新經濟就需要新的金融體系支撐。他指出,在9月宣布啟動的「互聯網推進器」計畫幫助下,未來5年內要讓1000家金融機構向新金融升級。而6月底成立的網商銀行,目前也已經有超過18萬家的小型微型企業成功獲得網商銀行總額超過30億人民幣的融資。\n\n\n 目前互聯網推進器的進展:\n * 超過200家銀行使用快捷支付,支付成功率超過95%。\n * 和60多家保險公司推出超過2000款保險服務。\n * 和90多家基金公司推出超過1600款基金產品。\n * 有70多家金融機構加入招財寶(螞蟻金服的理財產品),理財金額高達3400億。\n * 和20多家財產保險公司合作,融資擔保額高達1500億。\n * 超過38家金融機構和維他命數據平台(大數據分析)合作。\n\n\n今日開放的螞蟻金融雲將提供四種不同層面的服務:\n1.奠基底層架構的IAAS(Infrastructure as a Service),有8項產品;\n2.給開發者使用的開發平台PAAS(Platform as a Service),有17項產品;\n3.以數據計算分析為主的DAAS(Data as a Service),有5項產品;\n4.面向消費者的SAAS(Software as a Service),例如支付寶、餘額寶等商品。\n\n網路帶來從電商到金融的改變\n\n螞蟻金服首席技術架構師胡喜將從阿里巴巴到螞蟻金服至今10多年的業務發展分成三個階段:\n\n第一階段:2005-2007年\n業務範圍主要在網路電子商務和支付,每日交易筆數從幾萬筆大幅增加到幾百萬筆。當時的服務仍然是以IBM、Oracle、EMC等美商公司提供的集中式架構(統稱IOE)加上其他的開源程式。第一階段的產品包含擔保交易、CTU等。\n\n第二階段:2008-2010年\n業務範圍仍然是以網路電商支付為主,每日交易筆數從幾百萬筆增加到幾千萬筆,每日數據處理量也從TB增加到PB(petabyte,等於1024TB)。服務架構在技術平台上仍以IOE和螞蟻金服自行開發的中間軟體為主,數據平台則從RAC轉變為GP。第二階段的產品包含快捷支付、螞蟻小貸等。\n\n第三階段:2010-2014年\n業務範圍已經從電子商務拓展至網路金融,每日交易筆數從幾千萬到幾億筆,每日數據處理量從PB增加到EB(exabyte,等於1024PB)。服務架構在技術平台上已不再依賴IOE,以雲端計算、螞蟻中間軟體、阿里數據庫和大數據,提供ODPS開放數據處理服務。此時期的產品有餘額寶、網商銀行、芝麻信用等。\n\n而從2015年起的第四階段,螞蟻金服將成為提供金融商品,也提供背後分布式金融技術平台服務的公司。螞蟻金服執行長彭蕾也表示,自營和平台不是絕對的非此即彼的關係,不存在球員兼裁判的矛盾。另外,做平台的核心價值,除了保護資訊安全,將用戶價值最大化,更重要的就是將從阿里巴巴到螞蟻金服在電商到金融上累積的經驗和能力,轉為商業價值,向外輸出。\n\n\n(圖說:左為螞蟻金服集團總裁井賢棟,右為螞蟻金服執行長彭蕾。圖片來源:許文貞攝影。)\n\n\n(圖說:螞蟻金服高層一字排開接受媒體提問。圖片來源:許文貞攝影。)\n\n另外,由於阿里巴巴集團主席馬雲所提出,中國會有愈來愈多的中產階級,經濟將轉為內需消費為主的型態,彭蕾認為螞蟻金服不會「為了金融而做金融」,會繼續跟著人的需求而走。過去以小資族作為主要客群提出餘額寶等產品,未來也可能針對愈來愈多的中產階級提出對應的產品,例如做全球化的資產配置。\n\n投資36氪,合力打造中國最大私募股權投資平台\n\n螞蟻金服也在昨日宣布投資中國創業生態服務平台36氪。36氪最早在2010年是科技協作部落格,創辦人劉成誠表示,現在36氪的業務範圍包含融資平台「36氪融資」、「36氪媒體」報導創業相關資訊、位於北京中關村創業大街的「氪空間」等,雖然有融資平台,但過去是讓創業公司在平台上刊登融資資訊,是「網路資訊」而非「網路金融」,目前已服務超過33000家創業公司,有超過4400家公司刊登融資資訊,每天也有超過2000為專業機構投資人到平台上尋找適合投資的公司。\n\n\n(圖說:36氪創辦人劉成誠現身14日的螞蟻金服生態論壇,特別發表獲得螞蟻金服投資。圖片來源:許文貞攝影。)\n\n然而劉成誠指出,若創業公司只依賴機構的募資,募資來源單一,就容易受到股市等環境因素影響,造成融資困難。他也認為,當中國中產階級人數增加,要從中產階級到高資產階級的最好途徑就是透過股權投資。因此決定做網路網路股權類金融平台,轉做網路金融,不只能將資金配置到有前景的行業來投資,也能少量投資,分散風險。\n\r\n ",
|
100
|
+
:tags=>[
|
101
|
+
"阿里巴巴",
|
102
|
+
"支付寶",
|
103
|
+
"36氪",
|
104
|
+
"網路金融",
|
105
|
+
"FinTech",
|
106
|
+
"螞蟻金服",
|
107
|
+
"金融科技"
|
108
|
+
],
|
109
|
+
:imgs=>[
|
110
|
+
"https://3.bp.blogspot.com/-XBdLIajQDlU/ViDa_yn77bI/AAAAAAABUwc/o8EZd8oqAz8/s600/IMG_5650.JPG",
|
111
|
+
"https://3.bp.blogspot.com/-oMExH2XI8RM/ViDb0fa9jwI/AAAAAAABUww/J5WlVRvTXGI/s600/IMG_5657.JPG",
|
112
|
+
"https://3.bp.blogspot.com/-CBLEZs23d18/ViDcHiBG0LI/AAAAAAABUxE/sUgpZt_siNE/s600/IMG_5655.JPG",
|
113
|
+
"https://3.bp.blogspot.com/-xUEjAIXg92w/ViDcnwwxJpI/AAAAAAABUxc/BWI8Jki6dL8/s600/IMG_5641.JPG"
|
114
|
+
]
|
115
|
+
},
|
116
|
+
{
|
117
|
+
...
|
118
|
+
...
|
119
|
+
...
|
120
|
+
},
|
121
|
+
{
|
122
|
+
...
|
123
|
+
...
|
124
|
+
...
|
125
|
+
}]
|
126
|
+
```
|
127
|
+
|
128
|
+
|
@@ -83,14 +83,40 @@ class BNextRobot
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def _extract_feed(feed_id)
|
86
|
+
puts "#{feed_id}"
|
86
87
|
query_url = @domain[0..-2] + "#{feed_id}"
|
87
88
|
document = Oga.parse_html(open(query_url))
|
88
|
-
title =
|
89
|
-
author =
|
90
|
-
date =
|
91
|
-
content =
|
92
|
-
tags =
|
93
|
-
imgs =
|
89
|
+
title = nil;
|
90
|
+
author = nil;
|
91
|
+
date = nil;
|
92
|
+
content = nil;
|
93
|
+
tags = nil;
|
94
|
+
imgs = nil;
|
95
|
+
|
96
|
+
begin
|
97
|
+
title = document.xpath(TITLE_XPATH).text.force_encoding('utf-8')
|
98
|
+
rescue
|
99
|
+
end
|
100
|
+
begin
|
101
|
+
author = document.xpath(INFO_XPATH)[0].text.gsub('撰文者:'.force_encoding('ascii-8bit'), '').force_encoding('utf-8')
|
102
|
+
rescue
|
103
|
+
end
|
104
|
+
begin
|
105
|
+
date = document.xpath(INFO_XPATH)[1].text.gsub('發表日期:'.force_encoding('ascii-8bit'), '').force_encoding('utf-8')
|
106
|
+
rescue
|
107
|
+
end
|
108
|
+
begin
|
109
|
+
content = document.xpath(CONTENT_XPATH).text.force_encoding('utf-8')
|
110
|
+
rescue
|
111
|
+
end
|
112
|
+
begin
|
113
|
+
tags = document.xpath(TAG_XPATH).map { |i| i.text.force_encoding('utf-8') }
|
114
|
+
rescue
|
115
|
+
end
|
116
|
+
begin
|
117
|
+
imgs = document.xpath(IMGS_XPATH).map { |i| i.text.force_encoding('utf-8') }
|
118
|
+
rescue
|
119
|
+
end
|
94
120
|
Feed.new(title, author, date, tags, query_url, content, imgs)
|
95
121
|
end
|
96
122
|
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.6
|
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-
|
14
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: minitest
|
@@ -96,8 +96,9 @@ extensions: []
|
|
96
96
|
extra_rdoc_files: []
|
97
97
|
files:
|
98
98
|
- ".gitignore"
|
99
|
+
- ".travis.yml"
|
99
100
|
- Gemfile
|
100
|
-
-
|
101
|
+
- README.md
|
101
102
|
- Rakefile
|
102
103
|
- bin/bnext_robot
|
103
104
|
- bnext_robot.gemspec
|
data/Gemfile.lock
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
addressable (2.3.8)
|
5
|
-
ansi (1.5.0)
|
6
|
-
ast (2.1.0)
|
7
|
-
crack (0.4.2)
|
8
|
-
safe_yaml (~> 1.0.0)
|
9
|
-
hashdiff (0.2.2)
|
10
|
-
mini_portile (0.6.2)
|
11
|
-
minitest (5.8.1)
|
12
|
-
nokogiri (1.6.6.2)
|
13
|
-
mini_portile (~> 0.6.0)
|
14
|
-
oga (1.3.1)
|
15
|
-
ast
|
16
|
-
ruby-ll (~> 2.1)
|
17
|
-
ruby-ll (2.1.2)
|
18
|
-
ansi
|
19
|
-
ast
|
20
|
-
safe_yaml (1.0.4)
|
21
|
-
vcr (2.9.3)
|
22
|
-
webmock (1.22.1)
|
23
|
-
addressable (>= 2.3.6)
|
24
|
-
crack (>= 0.3.2)
|
25
|
-
hashdiff
|
26
|
-
xpath (2.0.0)
|
27
|
-
nokogiri (~> 1.3)
|
28
|
-
|
29
|
-
PLATFORMS
|
30
|
-
ruby
|
31
|
-
|
32
|
-
DEPENDENCIES
|
33
|
-
minitest
|
34
|
-
oga
|
35
|
-
vcr
|
36
|
-
webmock
|
37
|
-
xpath
|
38
|
-
|
39
|
-
BUNDLED WITH
|
40
|
-
1.10.6
|