NBA_info 0.1.1 → 0.1.2
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/{gemfile → Gemfile} +0 -0
- data/LICENSE +21 -0
- data/NBA_info-0.1.1.gem +0 -0
- data/NBA_info.gemspec +19 -0
- data/README.md +2 -1
- data/bin/application.rb +1 -2
- data/lib/NBA_info.rb +1 -1
- data/lib/NBA_info/NBA_info_ex.rb +47 -0
- data/lib/NBA_info/version.rb +4 -0
- data/spec/test.rb +1 -0
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 745d4057fa3d17e96d16f192a21a5ff22f9cb8e3
|
4
|
+
data.tar.gz: 027a55450f5a17b35817894349f013c9c8935fa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07a25bd876280fc9ee8a25bd3ea2a06676b459847b9ce3bce31a92e34da73b47165f95f34414464925bd1d8e4765209cfa733ced6c4e9a8df7626d24405d1321
|
7
|
+
data.tar.gz: ca61248a608f8a2db7361b70409c51a1da067f9fecf76a1c8ed66f35191b04eac3defd3df3bd27c7ee1b8612caea1099c3e2b0c2dc0ee4471c175be7c9a9a4fa
|
data/{gemfile → Gemfile}
RENAMED
File without changes
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 poweihuang, hsuchinwang, seanyean0507
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/NBA_info-0.1.1.gem
ADDED
Binary file
|
data/NBA_info.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'NBA_info/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'NBA_info'
|
6
|
+
s.version = NBA_INFO::VERSION
|
7
|
+
s.executables << 'application.rb'
|
8
|
+
s.add_development_dependency 'minitest'
|
9
|
+
s.add_development_dependency 'minitest-rg'
|
10
|
+
s.date = '2014-10-23'
|
11
|
+
s.summary = 'NBA information extractor and analyzer'
|
12
|
+
s.description = 'Extract and analyze NBA information from Yahoo sport and ESPN.com'
|
13
|
+
s.authors = ['poweihuang', 'hsuchinwang', 'seanyean0507']
|
14
|
+
s.email = 'benny59438@gmail.com'
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.homepage = 'https://github.com/seanyen0507/web_scraper'
|
18
|
+
s.license = 'MIT'
|
19
|
+
end
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#WebScraper HW
|
2
|
-
>this assignment scrapes the information and parse HTML directly from websites.
|
2
|
+
>this assignment scrapes the information and parse HTML directly from websites.
|
3
|
+
To run this project, you should execute the file from the following path '/lib/application.rb' with Ruby.
|
3
4
|
##Choice of website
|
4
5
|
</br>
|
5
6
|
First, we choose the NBA sports infomation on <http://scores.espn.go.com/nba/scoreboard> and scrape each game's starting lineup.
|
data/bin/application.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'NBA_info'
|
3
3
|
#require '../lib/NBA_info/NBA_info_ex.rb'
|
4
|
-
|
5
|
-
sam = Scraper.new
|
4
|
+
sam= Scraper.new
|
6
5
|
puts "Enter 1 to see starting lineup today, enter 2 to see any player's profile you want."
|
7
6
|
control = gets.chomp
|
8
7
|
control = control.to_i
|
data/lib/NBA_info.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'NBA_info/NBA_info_ex
|
1
|
+
require File.expand_path('../NBA_info/NBA_info_ex', __FILE__)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
3
|
+
# this is a class
|
4
|
+
class Scraper
|
5
|
+
|
6
|
+
|
7
|
+
def game
|
8
|
+
x, y, z, w, team_1 = [], [], [], [], []
|
9
|
+
|
10
|
+
doc = Nokogiri.HTML(open('http://scores.espn.go.com/nba/scoreboard'))
|
11
|
+
|
12
|
+
time = doc.xpath("//div[@class='game-status']//p")
|
13
|
+
time.each { |times| x << times.text }
|
14
|
+
team = doc.xpath("//div[@class='team-capsule']//a")
|
15
|
+
team.each { |teams| y << teams.text }
|
16
|
+
player = doc.xpath("//div[@style='display: block']\
|
17
|
+
//table[@class='game-stat-overview']//tbody//tr//td")
|
18
|
+
player.each { |p| team_1 << p.text }
|
19
|
+
|
20
|
+
for i in 0..(y.size) / 2 - 1
|
21
|
+
z << y[i * 2] + ' v.s ' + y[i * 2 + 1]
|
22
|
+
end
|
23
|
+
|
24
|
+
for i in 0..(team_1.size) / 5 - 1
|
25
|
+
w << team_1[i * 5] + "\t" + "#{team_1[i * 5 + 1]} #{team_1[i * 5 + 2]}" + \
|
26
|
+
' v.s ' + "#{team_1[i * 5 + 3]} #{team_1[i * 5 + 4]}"
|
27
|
+
end
|
28
|
+
|
29
|
+
schedule_table_upcoming = Hash[x.zip(z)]
|
30
|
+
[schedule_table_upcoming, w]
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def profile(name)
|
35
|
+
f = []
|
36
|
+
data = %w('PTS' 'REB' 'AST' 'PIE')
|
37
|
+
web_data_player = 'http://origin.nba.com/playerfile/'
|
38
|
+
web_data_player += name
|
39
|
+
doc1 = Nokogiri.HTML(open(web_data_player))
|
40
|
+
profile = doc1.xpath("//div[@class='sponsor-branding']\
|
41
|
+
//tr[@class='stats text-shadow']//td")
|
42
|
+
profile.each { |p| f << p.text }
|
43
|
+
player_profile = Hash[data.zip(f)]
|
44
|
+
[player_profile, f]
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/spec/test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: NBA_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- poweihuang
|
@@ -48,11 +48,16 @@ extensions: []
|
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
50
|
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE
|
53
|
+
- NBA_info-0.1.1.gem
|
54
|
+
- NBA_info.gemspec
|
51
55
|
- README.md
|
52
56
|
- Rakefile
|
53
57
|
- bin/application.rb
|
54
|
-
- gemfile
|
55
58
|
- lib/NBA_info.rb
|
59
|
+
- lib/NBA_info/NBA_info_ex.rb
|
60
|
+
- lib/NBA_info/version.rb
|
56
61
|
- spec/test.rb
|
57
62
|
homepage: https://github.com/seanyen0507/web_scraper
|
58
63
|
licenses:
|
@@ -74,9 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
79
|
version: '0'
|
75
80
|
requirements: []
|
76
81
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.2.2
|
78
83
|
signing_key:
|
79
84
|
specification_version: 4
|
80
85
|
summary: NBA information extractor and analyzer
|
81
|
-
test_files:
|
82
|
-
- spec/test.rb
|
86
|
+
test_files: []
|