livescore-parser 0.1.7 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5b04de5538c89368ef2ac62e392fe7e7d9052db
4
- data.tar.gz: c6fcd83aec2a801e9ee4ce40a728ac518cadc450
3
+ metadata.gz: 0063e2d8ae604cdfed8f325850b0649ea6e8785d
4
+ data.tar.gz: 0f1ec71d321d6962ce0ba91bd1a2d61dca5c1585
5
5
  SHA512:
6
- metadata.gz: 8a0d8faf2f3923898a0a8e7a9b6cebd9f03bdaae1e9fc90cb6874d4be187e08112e00a429c72fedb4cf85f7ad65ff7e83922f71e4151c61aaba37f1a114a509a
7
- data.tar.gz: 4cc2b3d09155184b67ecfb4674884ac523dfa7a1194f4716d6f242054e31e7408d9f5b35978c94546fcaa6a81b0eb19774d4a26224e8e259544b6650c8f5b4a2
6
+ metadata.gz: 4987586cef98c443fea3ee8317fd234c6d2b54c759a83ec6028a5cc1250f9d6de56c3aefd4844bbf5914c280b888e1aebdf96a1e7b2d852ce31f943fb5c7a2ef
7
+ data.tar.gz: 87065dfa7bb2d74bd4dfa45389c90db38b259d62597b1e74e74fc927b62aaa7ab875b2eed8d474fc75daaf504a89f4718d364565c0d221300902e3d4b24cbc0f
@@ -1,3 +1,5 @@
1
+ require 'pry'
2
+
1
3
  module LivescoreParser
2
4
  class Parser
3
5
 
@@ -18,7 +20,7 @@ module LivescoreParser
18
20
 
19
21
  def download(url)
20
22
  page = Nokogiri::HTML(@agent.get(url).body)
21
- data = build_hash page.css(".content tr")
23
+ data = build_hash page.css(".content .row, .content .row-gray")
22
24
  if data.empty?
23
25
  puts "Missing data"
24
26
  return nil
@@ -31,22 +33,22 @@ module LivescoreParser
31
33
  def build_hash(data)
32
34
  index = 0
33
35
  data.map do |row|
34
- if row.css('td').any?
36
+ if row.attr('class').match 'row-gray'
35
37
  index += 1
36
- time_raw = row.css('td')[0].text.strip
38
+ time_raw = row.css('.min').text.strip
37
39
  {
38
40
  wiersz: index,
39
41
  czas: (time_raw.match(/[0-9]+:[0-9]+/)) ? (Time.parse(time_raw) + 3600).strftime('%H:%M') : time_raw,
40
- gracz1: row.css('td')[1].text.strip,
41
- wynik1: row.css('td')[2].text.strip.match(/^[0-9\?]+/).to_s,
42
- gracz2: row.css('td')[3].text.strip,
43
- wynik2: row.css('td')[2].text.strip.match(/[0-9\?]+$/).to_s,
42
+ gracz1: row.css('.ply.tright').text.strip,
43
+ wynik1: row.css('.sco').text.strip.match(/^[0-9\?]+/).to_s,
44
+ gracz2: row.css('.sco + .ply').text.strip,
45
+ wynik2: row.css('.sco').text.strip.match(/[0-9\?]+$/).to_s,
44
46
  data: @date,
45
47
  kraj: @country
46
48
  }
47
49
  else
48
- @country = row.css('.league').text.strip
49
- @date = row.css('.date').text.strip
50
+ @country = row.css('.left strong').text.strip
51
+ @date = row.css('.right').text.strip
50
52
  next
51
53
  end
52
54
  end.compact
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.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Walusiak