top-headlines 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/top-headlines/source.rb +27 -7
- data/lib/top-headlines/version.rb +1 -1
- data/top-headlines.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1542f55042bc77f2f1aa23ecd4c89abb2c0ec9b8
|
4
|
+
data.tar.gz: 4850f0ae649a5d26a92bee8798fa4ba4d7299cde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad8ae4281a36bb7e7d6e8be29277998b62c46832b1918e5939839731a8234cb5bde867c8d04652047281ff15749d1234fa1c9b8d2a65e26d4dcd448e39d6d9cb
|
7
|
+
data.tar.gz: f583a444d894e18090028ce75ee4551f113a42a7c620ee0ade4d43ae6807032ff95dc0a2224d594f40d61d8d00aeb16b31a747cdfaea164cde6f8f7f49f31973
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# TopHeadlines
|
2
2
|
|
3
|
-
This gem allows users to view the top headlines from major news sources. Users can open the headlines directly from the command line. Functionality includes: Bloomberg, CNN, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times,
|
3
|
+
This gem allows users to view the top headlines from major news sources. Users can open the headlines directly from the command line. Functionality includes: BBC, Bloomberg, CNN, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, and Washington Post.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
data/lib/top-headlines/source.rb
CHANGED
@@ -54,19 +54,37 @@ class TopHeadlines::Source
|
|
54
54
|
headlines_selector: "a.wsj-headline-link",
|
55
55
|
urls_selector: "div.cb-col",
|
56
56
|
child_selector: "a.wsj-headline-link"
|
57
|
-
},
|
57
|
+
},
|
58
|
+
"POLITICO" => {
|
59
|
+
url: "http://www.politico.com/",
|
60
|
+
headlines_selector: "ul.headline-list a",
|
61
|
+
urls_selector: "ul.headline-list",
|
62
|
+
child_selector: "a"
|
63
|
+
},
|
64
|
+
"FIVETHIRTYEIGHT" => {
|
65
|
+
url: "http://fivethirtyeight.com/",
|
66
|
+
headlines_selector: "div#primary h3 a",
|
67
|
+
urls_selector: "div#primary h3",
|
68
|
+
child_selector: "a"
|
69
|
+
},
|
70
|
+
"WASHINGTON POST" => {
|
71
|
+
url: "https://www.washingtonpost.com/",
|
72
|
+
headlines_selector: "section#main-content a",
|
73
|
+
urls_selector: "section#main-content",
|
74
|
+
child_selector: "a"
|
75
|
+
},
|
76
|
+
"BBC" => {
|
77
|
+
url: "http://www.bbc.com/news",
|
78
|
+
headlines_selector: "div.column--primary span.title-link__title-text",
|
79
|
+
urls_selector: "div.column--primary",
|
80
|
+
child_selector: "a.title-link"
|
81
|
+
},
|
58
82
|
# "REDDIT" => { ## 429 Error
|
59
83
|
# url: "https://www.reddit.com/r/news/",
|
60
84
|
# headlines_selector: "p.title a.title.may-blank",
|
61
85
|
# urls_selector: "p.title",
|
62
86
|
# child_selector: "a"
|
63
87
|
# },
|
64
|
-
# "BBC" => {
|
65
|
-
# url: "http://www.bbc.com/news",
|
66
|
-
# headlines_selector: "div.column--primary span.title-link__title-text",
|
67
|
-
# urls_selector: "div.column--primary",
|
68
|
-
# child_selector: "a.title-link" ## NEEDS WORK returns e.g. /news/world-middle-east-36180184
|
69
|
-
# },
|
70
88
|
# "CBS" => {
|
71
89
|
# url: "http://www.cbsnews.com/",
|
72
90
|
# headlines_selector: "div.col-5.nocontent h3.title",
|
@@ -99,6 +117,7 @@ class TopHeadlines::Source
|
|
99
117
|
headlines_selector = source[:headlines_selector]
|
100
118
|
|
101
119
|
doc = Nokogiri::HTML(open(page_url))
|
120
|
+
|
102
121
|
headlines = doc.css(headlines_selector).map {|headline| headline.text.gsub("â", "'").gsub(/\n/,"").gsub(/\t/,"").strip}
|
103
122
|
end
|
104
123
|
|
@@ -109,6 +128,7 @@ class TopHeadlines::Source
|
|
109
128
|
child_selector = source[:child_selector]
|
110
129
|
|
111
130
|
doc = Nokogiri::HTML(open(page_url))
|
131
|
+
page_url = page_url[0...-5] if page_url[-4...-1]+page_url[-1] == "news" ### BBC CORNER CASE
|
112
132
|
urls = doc.css(urls_selector).children.css(child_selector).map {|url| url.attribute('href').value[0] == 'h' ? url.attribute('href').value : page_url + url.attribute('href').value}
|
113
133
|
end
|
114
134
|
end
|
data/top-headlines.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["zachnewburgh"]
|
10
10
|
spec.email = ["zach.newburgh@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{This gem allows users to view the top headlines from major news sources. Users can open the headlines directly from the command line for articles from Bloomberg, CNN, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times,
|
12
|
+
spec.summary = %q{This gem allows users to view the top headlines from major news sources. Users can open the headlines directly from the command line for articles from BBC, Bloomberg, CNN, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, and Washington Post.}
|
13
13
|
spec.homepage = "https://github.com/zachnewburgh/top-headlines-cli-gem"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: top-headlines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zachnewburgh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,7 +131,7 @@ rubygems_version: 2.4.5.1
|
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: This gem allows users to view the top headlines from major news sources.
|
134
|
-
Users can open the headlines directly from the command line for articles from
|
135
|
-
CNN, Forbes, Fox News, The Guardian, Huffington Post,
|
136
|
-
Wall Street Journal.
|
134
|
+
Users can open the headlines directly from the command line for articles from BBC,
|
135
|
+
Bloomberg, CNN, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post,
|
136
|
+
MSNBC, New York Times, Politico, Wall Street Journal, and Washington Post.
|
137
137
|
test_files: []
|