yahoo_news 0.1.1 → 0.1.2
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/Gemfile.lock +1 -1
- data/lib/yahoo_news.rb +8 -11
- data/lib/yahoo_news/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9630dd23228d9544465804a30fd47299eba9c9c2f635c2fc4519b6737f62e06d
|
4
|
+
data.tar.gz: be913b49abe5cd3fc0a88cca9fc78a1bb7555aa9b258efbd01786ee995cb1e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7c84b97553e151fe95150ad5678fa63b9a7d8f7e662ab4fb89613edce868ea0d6d16fc37aab2b7db2557439b24c37b8281e260d0b17e7f18b1002fc0bd33964
|
7
|
+
data.tar.gz: 773283f88a058c6c87234cc34e9f493d2768ba132b0a14c8aa3f117aeaadf983db29a9cd0ef802732dda7a7a54cb9f114b38bce15fa801791fcdc84a66d5dbf5
|
data/Gemfile.lock
CHANGED
data/lib/yahoo_news.rb
CHANGED
@@ -8,27 +8,24 @@ module YahooNews
|
|
8
8
|
file = open(input_url)
|
9
9
|
str = file.read
|
10
10
|
|
11
|
-
# get
|
12
|
-
|
11
|
+
# get time
|
12
|
+
str_time = str.match(/\d+時\d+分更新/)
|
13
13
|
|
14
14
|
# news_table
|
15
|
-
str = str.match(
|
15
|
+
str = str.match(%r(<a href="https://news.yahoo.co.jp/pickup/\d+">.*<img src=".+></a></td></tr><tr><td>))
|
16
16
|
|
17
17
|
# get urls
|
18
|
-
|
18
|
+
urls = URI.extract(str[0],['https'])
|
19
19
|
|
20
20
|
# get article_titles
|
21
|
-
|
22
|
-
|
21
|
+
titles = str[0].gsub!(/<("[^"]*"|'[^']*'|[^'">])*>/, "")
|
22
|
+
titles = titles.split("・")
|
23
23
|
|
24
24
|
# Make it hash structure.
|
25
|
-
output_news = []
|
26
|
-
for i in 0..str_urls.size-1 do
|
27
|
-
output_news[i] = {"#{str_titles[i]}" => "#{str_urls[i]}"}
|
28
|
-
end
|
25
|
+
output_news = titles.map.with_index { |title, i| { title: title, url: urls[i] } }
|
29
26
|
|
30
27
|
# output news!
|
31
|
-
puts
|
28
|
+
puts str_time
|
32
29
|
puts output_news
|
33
30
|
end
|
34
31
|
end
|
data/lib/yahoo_news/version.rb
CHANGED