atp_scraper 0.1.0 → 0.2.0
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/README.md +9 -7
- data/lib/atp_scraper/ranking.rb +11 -2
- data/lib/atp_scraper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f8a982c8a114ded0d06e9dc11d027d5dadc2f2c
|
4
|
+
data.tar.gz: ee462bc2065b283ee4699a2b82d52ee582777828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5c00331c5873c6838b18735fb131070269ec896b155e53e9f211877d64070263fe9d5051b64da33e6484aaa8ba585e2b9a2322d21b717fb9921e6166a025cca
|
7
|
+
data.tar.gz: 87d432f14e2060b5995840fc59f527ee938d844e9a88827fe3d46728d95b839342e6b98dfc085f4d8fc8ba0d32f6e35755bc199614fdd5e4324004e7394e0780
|
data/README.md
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
[](https://travis-ci.org/mosuke5/atp_scraper)
|
2
2
|
# AtpScraper
|
3
3
|
|
4
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/atp_scraper`. To experiment with that code, run `bin/console` for an interactive prompt.
|
5
|
-
|
6
|
-
TODO: Delete this and the text above, and describe your gem
|
7
|
-
|
8
4
|
## Installation
|
9
5
|
|
10
6
|
Add this line to your application's Gemfile:
|
@@ -25,15 +21,19 @@ Or install it yourself as:
|
|
25
21
|
```ruby
|
26
22
|
require "atp_scraper"
|
27
23
|
|
28
|
-
# Get Singles Ranking
|
24
|
+
# Get Singles Ranking TOP100
|
29
25
|
AtpScraper::Ranking.get
|
30
26
|
# Response Json
|
31
27
|
# {
|
28
|
+
# rannking: "5"
|
32
29
|
# player_name: "Rafael Nadal",
|
33
30
|
# player_url_name: "rafael-nadal",
|
34
31
|
# player_id: "n409"
|
35
32
|
# }
|
36
33
|
|
34
|
+
# Get Singles Ranking 101-200
|
35
|
+
AtpScraper::Ranking.get("101-200")
|
36
|
+
|
37
37
|
# Get Player Activity. For Example Rafael Nadal's activity in 2016
|
38
38
|
AtpScraper::Activity.get("n409", 2016)
|
39
39
|
# Response Json
|
@@ -61,8 +61,10 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
61
61
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
62
62
|
|
63
63
|
## Contributing
|
64
|
-
|
65
|
-
|
64
|
+
- Fork the project.
|
65
|
+
- Make your feature addition or bug fix, write tests.
|
66
|
+
- Commit, do not mess with rakefile, version.
|
67
|
+
- Make a pull request.
|
66
68
|
|
67
69
|
|
68
70
|
## License
|
data/lib/atp_scraper/ranking.rb
CHANGED
@@ -10,12 +10,16 @@ module AtpScraper
|
|
10
10
|
# Scrape ranking data
|
11
11
|
class Ranking
|
12
12
|
class << self
|
13
|
-
def get
|
14
|
-
request_uri =
|
13
|
+
def get(rank_range = nil)
|
14
|
+
request_uri = build_uri(rank_range)
|
15
15
|
ranking_doc = AtpScraper::Html.get_and_parse(request_uri)
|
16
16
|
pickup_ranking_data(ranking_doc)
|
17
17
|
end
|
18
18
|
|
19
|
+
def build_uri(rank_range = "0-100")
|
20
|
+
"/en/rankings/singles?rankRange=#{rank_range}"
|
21
|
+
end
|
22
|
+
|
19
23
|
def pickup_ranking_data(ranking_doc)
|
20
24
|
result = []
|
21
25
|
search_player_doc(ranking_doc).each do |player_doc|
|
@@ -31,12 +35,17 @@ module AtpScraper
|
|
31
35
|
def pickup_player_data(player_doc)
|
32
36
|
url = pickup_player_url(player_doc)
|
33
37
|
{
|
38
|
+
ranking: pickup_player_rank(player_doc),
|
34
39
|
player_name: pickup_player_name(player_doc),
|
35
40
|
player_url_name: get_url_name(url),
|
36
41
|
player_id: get_url_id(url)
|
37
42
|
}
|
38
43
|
end
|
39
44
|
|
45
|
+
def pickup_player_rank(player_doc)
|
46
|
+
player_doc.css(".rank-cell").first.content.strip
|
47
|
+
end
|
48
|
+
|
40
49
|
def pickup_player_name(player_doc)
|
41
50
|
player_doc.css(".player-cell").first.content.strip
|
42
51
|
end
|
data/lib/atp_scraper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atp_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mosuke5
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|