sutazekarate 0.0.9 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sutazekarate/competition.rb +45 -0
- data/lib/sutazekarate/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9affd5ab82a716e54b9e0d6eb78ae74c3898327e0d32949588dd36218a163e46
|
4
|
+
data.tar.gz: baa04e8b11ad761622ae6dd004e5baffff30f3663deb2de5f80f2224f4e06d7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 188676dca6c78d765ca754a0520f7371f4bab32a2ed9413dd431d14c931a3e2ff8ea87a6f2cbc751573b37fffad343a9ad2ea9c4c248e9dc9129b26e7bde8b78
|
7
|
+
data.tar.gz: 3aba9d16de529537c4b8aa00db065fa84665849fa0f473296c2a5bf85399d0186175e30706779c5940fa111146b2ccc44f9bc217ab965a29454dcce4320ac27f
|
@@ -13,6 +13,7 @@ module Sutazekarate
|
|
13
13
|
include Concurrent::Async
|
14
14
|
|
15
15
|
attribute :id
|
16
|
+
attribute :image_url
|
16
17
|
attribute :starts_at
|
17
18
|
attribute :name
|
18
19
|
attribute :club
|
@@ -20,6 +21,7 @@ module Sutazekarate
|
|
20
21
|
attribute :note
|
21
22
|
attribute :registration_starts_at
|
22
23
|
attribute :registration_ends_at
|
24
|
+
attribute :attachments
|
23
25
|
|
24
26
|
def categories
|
25
27
|
@categories ||= begin
|
@@ -55,6 +57,45 @@ module Sutazekarate
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
60
|
+
def self.find(id)
|
61
|
+
logger.debug("Fetching competition with id #{id}")
|
62
|
+
|
63
|
+
response = HTTP.get("https://www.sutazekarate.sk/sutaze_sutazinf.php?sutaz=#{id}")
|
64
|
+
html = Nokogiri::HTML5.fragment(response.body.to_s)
|
65
|
+
|
66
|
+
image_path = html.search('img.img-responsive.no-margin').attr('src').value
|
67
|
+
image_url = "https://www.sutazekarate.sk/#{image_path}"
|
68
|
+
name = html.search('h3.section-title-inner').text.strip.rpartition(' - ').first
|
69
|
+
club = html.search('.table1 tr:nth-child(1) td:nth-child(2)').text.strip
|
70
|
+
|
71
|
+
starts_at = Date.parse(html.search('.table1 tr:nth-child(2) td:nth-child(2)').text.strip)
|
72
|
+
|
73
|
+
registration_info = html.search('.table1 tr:nth-child(4) td:nth-child(2)').text.strip
|
74
|
+
registration_starts_at, registration_ends_at = registration_info.split(' - ').map do |date|
|
75
|
+
Date.parse(date)
|
76
|
+
end
|
77
|
+
|
78
|
+
attachments = html.search('.table1 tr').reduce([]) do |acc, row|
|
79
|
+
acc += row.search('td:nth-child(2) a[target="_blank"]').map do |a|
|
80
|
+
"https://www.sutazekarate.sk/#{a.attr('href')}"
|
81
|
+
end
|
82
|
+
.grep_v(/\.php/)
|
83
|
+
|
84
|
+
acc
|
85
|
+
end
|
86
|
+
|
87
|
+
Competition.new(
|
88
|
+
id:,
|
89
|
+
image_url:,
|
90
|
+
starts_at:,
|
91
|
+
name:,
|
92
|
+
club:,
|
93
|
+
registration_starts_at:,
|
94
|
+
registration_ends_at:,
|
95
|
+
attachments:,
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
58
99
|
def self.all(year: Date.today.year)
|
59
100
|
logger.debug("Fetching competitions for year #{year}")
|
60
101
|
response = HTTP.get("https://www.sutazekarate.sk/ajax/av_sutaze.php?lang=sk&r=#{year}&sort=datum&order=desc&limit=1000&offset=0")
|
@@ -62,7 +103,10 @@ module Sutazekarate
|
|
62
103
|
rows.map do |row|
|
63
104
|
starts_at = Date.parse(row['datum'])
|
64
105
|
content = Nokogiri::HTML5.fragment(row['obsah'])
|
106
|
+
image = Nokogiri::HTML5.fragment(row['obrazok'])
|
65
107
|
|
108
|
+
image_path = image.search('img').attr('src').value
|
109
|
+
image_url = "https://www.sutazekarate.sk/#{image_path}"
|
66
110
|
name = content.search('h4').first.text.strip
|
67
111
|
club_element = content.search('h5').first
|
68
112
|
club = club_element.text.strip
|
@@ -85,6 +129,7 @@ module Sutazekarate
|
|
85
129
|
|
86
130
|
Competition.new(
|
87
131
|
id:,
|
132
|
+
image_url:,
|
88
133
|
starts_at:,
|
89
134
|
name:,
|
90
135
|
club:,
|
data/lib/sutazekarate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sutazekarate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed Al Hafoudh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
|
-
rubygems_version: 3.5.
|
153
|
+
rubygems_version: 3.5.23
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: Web scraper for www.sutazekarate.sk
|