Class: Transfermarkt::Club
- Inherits:
-
EntityBase
- Object
- EntityBase
- Transfermarkt::Club
- Defined in:
- lib/transfermarkt/club.rb
Instance Attribute Summary collapse
-
#club_uri ⇒ Object
Returns the value of attribute club_uri.
-
#country ⇒ Object
Returns the value of attribute country.
-
#name ⇒ Object
Returns the value of attribute name.
-
#player_uris ⇒ Object
Returns the value of attribute player_uris.
-
#players ⇒ Object
Returns the value of attribute players.
Class Method Summary collapse
Methods inherited from EntityBase
Constructor Details
This class inherits a constructor from Transfermarkt::EntityBase
Instance Attribute Details
#club_uri ⇒ Object
Returns the value of attribute club_uri.
3 4 5 |
# File 'lib/transfermarkt/club.rb', line 3 def club_uri @club_uri end |
#country ⇒ Object
Returns the value of attribute country.
3 4 5 |
# File 'lib/transfermarkt/club.rb', line 3 def country @country end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/transfermarkt/club.rb', line 3 def name @name end |
#player_uris ⇒ Object
Returns the value of attribute player_uris.
3 4 5 |
# File 'lib/transfermarkt/club.rb', line 3 def player_uris @player_uris end |
#players ⇒ Object
Returns the value of attribute players.
3 4 5 |
# File 'lib/transfermarkt/club.rb', line 3 def players @players end |
Class Method Details
.fetch_by_club_uri(club_uri, fetch_players = false) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/transfermarkt/club.rb', line 9 def self.fetch_by_club_uri(club_uri, fetch_players = false) req = self.get("/#{club_uri}", headers: {"User-Agent" => UserAgents.rand()}) if req.code != 200 nil else club_html = Nokogiri::HTML(req.parsed_response) = {} puts "**** parsing club #{club_uri}" [:club_uri] = club_uri [:name] = club_html.xpath('//*[@class="spielername-profil"]').text.strip [:country] = club_html.xpath('//*[@id="land_select_breadcrumb"]//option[@selected="selected"]').text.strip [:player_uris] = club_html.xpath('//*[@id="yw1"]//table//tr//td[2]//a[contains(@href,"profil")]').collect{|player_html| player_html["href"]} [:players] = [] if fetch_players [:player_uris].each do |player_uri| [:players] << Transfermarkt::Player.fetch_by_profile_uri(URI.encode(player_uri)) end end puts "fetched club players for #{[:name]}" self.new() end end |