livescore-parser 0.2.3 → 0.2.4
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/lib/livescore-parser/parser.rb +7 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a9e6cd30830480b169ee638e5aed2ede8e7cb7e
|
4
|
+
data.tar.gz: 2344222e314be4c29c7069308692ca547a2ab796
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8245c7787aaad32c3d5f7e0aea1970910b4a3e8341dcacd237ae2e24b1ff96d739ed5407f368ba5ec0fab60868a3bbff25ac8def7e52967a5b4d7e0e4f43205a
|
7
|
+
data.tar.gz: bfb49f003dc2d990eb7eefc8e0dc0d70b4a5860aceb54acb2b84d6b977b9be75f7ff6a89b30fd563a610c320e1e4f2a392bfcb4acf1e88e32142547363116927
|
@@ -5,7 +5,11 @@ module LivescoreParser
|
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@agent = Mechanize.new
|
8
|
-
@
|
8
|
+
@offset = Time.new.utc_offset + (7 * 3600)
|
9
|
+
cookie = Mechanize::Cookie.new('tz', (@offset / 3600).to_s)
|
10
|
+
cookie.path = '/'
|
11
|
+
cookie.domain = '.www.livescore.com'
|
12
|
+
@agent.cookie_jar.add(cookie)
|
9
13
|
end
|
10
14
|
|
11
15
|
# Runs dynamic-sprites command.
|
@@ -20,7 +24,7 @@ module LivescoreParser
|
|
20
24
|
private
|
21
25
|
|
22
26
|
def download(url)
|
23
|
-
page = Nokogiri::HTML(@agent.get(url
|
27
|
+
page = Nokogiri::HTML(@agent.get(url).body)
|
24
28
|
data = build_hash page.css(".content > *")
|
25
29
|
if data.empty?
|
26
30
|
puts "Missing data"
|
@@ -39,7 +43,7 @@ module LivescoreParser
|
|
39
43
|
time_raw = row.css('.min').text.strip
|
40
44
|
{
|
41
45
|
wiersz: index,
|
42
|
-
czas: (time_raw.match(/[0-9]+:[0-9]+/)) ? (Time.parse(time_raw) + Time.new.utc_offset).strftime('%H:%M') : time_raw,
|
46
|
+
czas: (time_raw.match(/[0-9]+:[0-9]+/)) ? (Time.parse(time_raw) + Time.new.utc_offset - @offset).strftime('%H:%M') : time_raw,
|
43
47
|
gracz1: row.css('.ply.tright').text.strip,
|
44
48
|
wynik1: row.css('.sco').text.strip.match(/^[0-9\?]+/).to_s,
|
45
49
|
gracz2: row.css('.sco + .ply').text.strip,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: livescore-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Walusiak
|
@@ -85,8 +85,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
88
|
+
rubygems_version: 2.4.5
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: TV Channel parser
|
92
92
|
test_files: []
|
93
|
+
has_rdoc:
|