scotsman_obituaries 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 67127d4a4006a9601902aabf73d9bfd1110d6578
4
+ data.tar.gz: 0abea0a938bea6ab9d323afc4bddc1569ce1056a
5
+ SHA512:
6
+ metadata.gz: 01275c6869b398516657082c8c8d07cea78719aaacf4ca78a1604677381ab7ef9ec645dca29e1a6edd6e0e83f56136754d331838d14a3a9e22384b67f69e185d
7
+ data.tar.gz: 88c731883d5beaf0c31ce238c812f108587122f288a4a78cf06c5d13329f42411cf75d2780535213b7bb41ba1b226fb172c4b920cd3b5557eef4421e56f5b9fd
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ B�f`�+T�(Znz�k�!^o�p��,-������o�/�KW-v$��}^���z���Z=~����r�~��B'�� �r����K��\�h�"�u{�*�߽�֝�T� ��U�Zrs6��6��I����l� _6�]�֟k�Π�C�jF����-]ю�c����X�Q�s<W�M��q���YӇЯ��4oyF��g�Ò���L�YMj�$��ۉ�Z#� �;�*��BO��t�d|�|j&�/���,8d�ܿ��E
data.tar.gz.sig ADDED
Binary file
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: scotsman_obituaries.rb
4
+
5
+ require 'nokorexi'
6
+ require 'open-uri'
7
+
8
+ # desc: Web scrapes the search results from the Scotsman and
9
+ # Edinburgh Evening News obituary annoucements from
10
+ # http://announce.jpress.co.uk/?source=jpsc_scot
11
+
12
+ class ScotsmanObituaries
13
+
14
+ def initialize()
15
+
16
+ raw_cookie = {
17
+ Name: 'acceptsCookies',
18
+ Value: 'accepts',
19
+ Host: 'www.edinburghnews.scotsman.com',
20
+ Path: '/',
21
+ Expires: 'Fri, 10 Oct 2025 16:53:34 GMT',
22
+ Secure: 'No',
23
+ HttpOnly: 'No'
24
+ }
25
+
26
+ @cookie = raw_cookie.to_a.map {|key,val| "%s=%s" % [key, val]}.join '; '
27
+
28
+ @url_base = 'http://announce.jpress.co.uk/'
29
+
30
+ end
31
+
32
+ def search(title: '', date_range: :last_week)
33
+
34
+ raise "ScotsmanObituaries: Please enter a title to search" if title.empty?
35
+
36
+ days = {
37
+ today: 1,
38
+ last_week: 7,
39
+ last_month: 31
40
+ }
41
+
42
+ url = ''
43
+
44
+ url = @url_base + "search?keywords=#{title}&" + \
45
+ "date_limit=#{days[date_range.to_sym]}&date=" + \
46
+ "&type=obit&_fstatus=search&s_source=jpsc_scot"
47
+
48
+ s = open(url, "Cookie" => @cookie).read
49
+ doc = Nokorexi.new(s).to_doc
50
+ e = doc.at_css '.results'
51
+
52
+ e.xpath('li/div[@class="notice"]').inject([]) do |r,notice|
53
+ heading = notice.text('h2/a')
54
+ short_text = notice.text('p').strip
55
+ pubdate = Date.parse(notice.\
56
+ element('meta[@itemprop="datePublished"]').attributes[:content])
57
+ r << {heading: heading, short_text: short_text, pubdate: pubdate}
58
+ end
59
+
60
+ end
61
+
62
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scotsman_obituaries
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE1MTEwMjE3MDc0OVoXDTE2MTEwMTE3MDc0OVowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCA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 - !ruby/object:Gem::Dependency
37
+ name: nokorexi
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.3'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.3.1
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.3'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.3.1
56
+ description:
57
+ email: james@r0bertson.co.uk
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/scotsman_obituaries.rb
63
+ homepage: https://github.com/jrobertson/scotsman_obituaries
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.8
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: A web scraper to scrape the search results from the Scotsman and Edinburgh
87
+ Evening News obituary annoucements
88
+ test_files: []
metadata.gz.sig ADDED
Binary file