bbc10 1.0.0

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.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +19 -0
  3. data/README +11 -0
  4. data/bin/bbc10 +14 -0
  5. data/lib/bbc10/scraper.rb +20 -0
  6. metadata +58 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 22f115e3b649e6db52f72a2d1ab51c5f9cb48887a3044f4bb412ae039533fa96
4
+ data.tar.gz: cf13b1c7a2e2b8188d91e80168bf5ce465275839c8d7d313014f511135b577ee
5
+ SHA512:
6
+ metadata.gz: 6e177f72af8c3b5845efc90709ca959be29c23032b5a55463b1c685745cb2f0594c0071e627493a3782487f342abff6f41915ff39342c562a18885cab9101b94
7
+ data.tar.gz: 02031d5fd330dac9ebc5eaac11591761491c8030fed97036bc7ea14a54a9d61c4695d2901446d5003971c8a00c32d682b1a8555a841ed3fae241b16e8aa75a24
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2019 Ian s33dco
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README ADDED
@@ -0,0 +1,11 @@
1
+ # Bbc10
2
+
3
+ Scrape the 10 mst read stories from www.bbc.co.uk to your terminal window.
4
+
5
+ Install the gem:
6
+
7
+ $ gem install bbc10
8
+
9
+ ## Usage
10
+
11
+ ``` bbc10 | less ```
data/bin/bbc10 ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/bbc10/scraper'
3
+
4
+ module Bbc10
5
+ URL = 'https://www.bbc.co.uk/news'
6
+ puts "\n\nScraping the most read from #{URL}..."
7
+ page = Scraper::read_page(URL)
8
+ links = Scraper::get_links(page)
9
+ links.each do | link |
10
+ puts "\n\n#{link}\n\n\n"
11
+ story = Scraper::read_page(link)
12
+ Scraper::scrape_story(story)
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "open-uri"
4
+ require 'nokogiri'
5
+
6
+ module Bbc10
7
+ module Scraper
8
+ def self.read_page(url)
9
+ Nokogiri::HTML(open(url).read)
10
+ end
11
+
12
+ def self.get_links(page)
13
+ page.css('.nw-c-most-read__items a').map{|link| 'https://www.bbc.co.uk/' << link['href']}
14
+ end
15
+
16
+ def self.scrape_story(story)
17
+ story.css('.story-body__inner p').map(&:content).each{|para| puts "#{para}\n\n"}
18
+ end
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bbc10
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - s33d
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ # Bbc10
15
+
16
+ Scrape the 10 mst read stories from www.bbc.co.uk to your terminal window.
17
+
18
+ Install the gem:
19
+
20
+ $ gem install bbc10
21
+
22
+ ## Usage
23
+
24
+ ``` bbc10 | less ```
25
+ email: code@s33d.co
26
+ executables:
27
+ - bbc10
28
+ extensions: []
29
+ extra_rdoc_files: []
30
+ files:
31
+ - LICENSE
32
+ - README
33
+ - bin/bbc10
34
+ - lib/bbc10/scraper.rb
35
+ homepage: https://github.com/s33dco/bbc10
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message: Thanks for installing ♥️ s33dco
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '2.5'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.0.3
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Scrape the ten most read stories from www.bbc.co.uk to your terminal window
58
+ test_files: []