get_news 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -16
- data/get_news-0.1.0.gem +0 -0
- data/lib/get_news.rb +29 -1
- data/lib/get_news/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfa2d5ef7d89cee5bf2dc76338600afdf091895e
|
4
|
+
data.tar.gz: 9d657ef7e18e86ec96d787316e2949769caa20b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e28ed028ca0695e7cbf6f08c49aa95d4e11e6467c3b8067de4110f6e5115a958c26284c9c31a3e72a3f942d5d13dc074cc9875e195278541bb956c772e4ac6b
|
7
|
+
data.tar.gz: dff7eb006f354ef9e25a1367b5fffe8a6acedfea009bc81dee740d08aee81966628089b37dff9cc8b6b0d1e3b72a6f6268348266158948a0ea7ac44c35bf096b
|
data/README.md
CHANGED
@@ -1,42 +1,77 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/sinsnk/get_news.svg?branch=master)](https://travis-ci.org/sinsnk/get_news)
|
2
|
-
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/get_news.svg)](http://badge.fury.io/rb/get_news)
|
3
|
+
=======
|
4
|
+
# GetNews の概要
|
3
5
|
|
4
|
-
|
6
|
+
GetNews とは Google ニュースをキーワードで検索し、該当するニュースのタイトルを配列形式で取得するためのライブラリです。
|
5
7
|
|
6
|
-
TODO: Delete this and the text above, and describe your gem
|
7
8
|
|
8
|
-
##
|
9
|
+
## インストール
|
10
|
+
|
11
|
+
アプリケーションの Gemfile に以下の行を記述します。
|
9
12
|
|
10
|
-
Add this line to your application's Gemfile:
|
11
13
|
|
12
14
|
```ruby
|
13
15
|
gem 'get_news'
|
14
16
|
```
|
15
17
|
|
16
|
-
|
18
|
+
その後、以下のコマンドを実行します。
|
17
19
|
|
18
20
|
$ bundle
|
19
21
|
|
20
|
-
|
22
|
+
もしくは以下のコマンドを実行します。
|
21
23
|
|
22
24
|
$ gem install get_news
|
23
25
|
|
24
|
-
|
26
|
+
GetNews をアンインストールする場合は以下のコマンドを実行します。
|
27
|
+
|
28
|
+
$ gem uninstall get_news
|
29
|
+
|
30
|
+
|
31
|
+
## 機能
|
32
|
+
* Google ニュースをキーワード検索
|
33
|
+
|
34
|
+
## メソッド一覧
|
35
|
+
|
36
|
+
get_news(search_word, news_count)
|
37
|
+
|
38
|
+
search_word : String (検索キーワード)
|
39
|
+
news_count : Integer (取得条件)
|
40
|
+
|
41
|
+
|
42
|
+
## 使用方法
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'get_news'
|
46
|
+
|
47
|
+
#Google ニュースをキーワードで検索
|
48
|
+
@main = GetNews::Main.new
|
49
|
+
result = @main.get_news('IoT', 20)
|
50
|
+
|
51
|
+
#結果表示
|
52
|
+
for title in result do
|
53
|
+
print("title : " + title + "¥n")
|
54
|
+
end
|
55
|
+
|
56
|
+
```
|
57
|
+
|
58
|
+
## 開発/テスト
|
25
59
|
|
26
|
-
|
60
|
+
この Gem には MiniTest による単体テスト用コードが用意されています。
|
61
|
+
また Travis CI と連携し、テストの自動化を行っています。
|
27
62
|
|
28
|
-
|
63
|
+
https://travis-ci.org/sinsnk/get_news
|
29
64
|
|
30
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
65
|
|
32
|
-
|
66
|
+
##対応予定機能
|
33
67
|
|
34
|
-
|
68
|
+
* 日付、ニュースカテゴリ情報の追加
|
69
|
+
* 複数キーワードによる AND / OR 検索
|
35
70
|
|
36
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/get_news. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
37
71
|
|
72
|
+
## ライセンス
|
38
73
|
|
39
|
-
|
74
|
+
このソースコードのライセンスは [MIT License](http://opensource.org/licenses/MIT) です。
|
40
75
|
|
41
|
-
|
76
|
+
Copyright (c) 2015 AIIT Framework Development Team D
|
42
77
|
|
data/get_news-0.1.0.gem
ADDED
Binary file
|
data/lib/get_news.rb
CHANGED
@@ -1,7 +1,35 @@
|
|
1
1
|
require "get_news/version"
|
2
|
+
require "nokogiri"
|
3
|
+
require "open-uri"
|
4
|
+
require "uri"
|
2
5
|
|
3
6
|
module GetNews
|
4
7
|
class Main
|
5
|
-
|
8
|
+
def get_news(search_word, news_count)
|
9
|
+
if news_count < 1
|
10
|
+
return
|
11
|
+
end
|
12
|
+
|
13
|
+
url = URI.escape('https://news.google.com/news?ned=us&ie=UTF-8&oe=UTF-8&q=' + search_word + '&output=atom&num=' + news_count.to_s + '&hl=ja')
|
14
|
+
|
15
|
+
charset = nil
|
16
|
+
xml = open(url) do |f|
|
17
|
+
charset = f.charset
|
18
|
+
f.read
|
19
|
+
end
|
20
|
+
|
21
|
+
doc = Nokogiri::XML(xml) do |config|
|
22
|
+
config.strict.nonet
|
23
|
+
end
|
24
|
+
|
25
|
+
title_array = []
|
26
|
+
doc.xpath('//xmlns:title').each_with_index do |val, index|
|
27
|
+
if index != 0
|
28
|
+
title_array.push(val.text)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
title_array
|
33
|
+
end
|
6
34
|
end
|
7
35
|
end
|
data/lib/get_news/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get_news
|
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
|
- sinsnk
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- Rakefile
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
|
+
- get_news-0.1.0.gem
|
72
73
|
- get_news.gemspec
|
73
74
|
- lib/get_news.rb
|
74
75
|
- lib/get_news/version.rb
|