From c7c4e52610cf74e910336d591ed1daae2bcf0bec Mon Sep 17 00:00:00 2001 From: Elad Meidar Date: Thu, 3 Jul 2014 22:29:46 +0300 Subject: [PATCH] [FIX] fixing league fetcher --- lib/transfermarkt.rb | 1 + lib/transfermarkt/club.rb | 2 +- lib/transfermarkt/league.rb | 22 +- lib/transfermarkt/live_game.rb | 2 +- lib/transfermarkt/player.rb | 6 +- spec/static_htmls/premier_league_html.html | 3694 ++++++++++++++++++++ spec/units/league_spec.rb | 26 + transfermarkt.gemspec | 1 + 8 files changed, 3738 insertions(+), 16 deletions(-) create mode 100644 spec/static_htmls/premier_league_html.html create mode 100644 spec/units/league_spec.rb diff --git a/lib/transfermarkt.rb b/lib/transfermarkt.rb index 14900cb..b6a8a01 100644 --- a/lib/transfermarkt.rb +++ b/lib/transfermarkt.rb @@ -3,6 +3,7 @@ module Transfermarkt require 'httparty' require 'nokogiri' + require 'useragents' autoload :EntityBase, 'transfermarkt/entity_base' autoload :Player, 'transfermarkt/player' diff --git a/lib/transfermarkt/club.rb b/lib/transfermarkt/club.rb index d932db6..76fde2c 100644 --- a/lib/transfermarkt/club.rb +++ b/lib/transfermarkt/club.rb @@ -9,7 +9,7 @@ class Club < Transfermarkt::EntityBase def self.fetch_by_club_uri(club_uri, fetch_players = false) puts "fetching club #{club_uri}" - req = self.get("/#{club_uri}", headers: {"User-Agent" => Transfermarkt::USER_AGENT}) + req = self.get("/#{club_uri}", headers: {"User-Agent" => UserAgents.rand()}) if req.code != 200 nil else diff --git a/lib/transfermarkt/league.rb b/lib/transfermarkt/league.rb index b6844a1..fd6a70d 100644 --- a/lib/transfermarkt/league.rb +++ b/lib/transfermarkt/league.rb @@ -8,7 +8,7 @@ class League < Transfermarkt::EntityBase :club_uris def self.fetch_clubs_and_uris_by_league_uri(league_uri) - req = self.get("/#{league_uri}", headers: {"User-Agent" => Transfermarkt::USER_AGENT}) + req = self.get("/#{league_uri}", headers: {"User-Agent" => ::UserAgents.rand()}) if req.code != 200 nil else @@ -16,11 +16,11 @@ def self.fetch_clubs_and_uris_by_league_uri(league_uri) options = {} options[:league_uri] = league_uri - options[:name] = league_html.xpath('//*[@id="wb_seite"]/table/tr[1]/td[2]/h1/text()').text.strip.gsub(" -","") - options[:country] = league_html.xpath('//*[@id="wb_seite"]/table/tr[1]/td[2]/h1/a').text + options[:name] = league_html.xpath('//select[@id="wettbewerb_select_breadcrumb"]//option[@selected="selected"]')[0].text + options[:country] = league_html.xpath('//select[@id="land_select_breadcrumb"]//option[@selected="selected"]').text - club_uris = league_html.xpath('//table[@id="vereine"]//tr//td[2]//a[@class="s10"]').collect{|player_html| player_html["href"]} - club_names = league_html.xpath('//table[@id="vereine"]//tr//td[2]//a[@class="s10"]').collect{|player_html| player_html.text } + club_uris = league_html.xpath('//*[@id="yw1"]//table//tr//td[2]//a[1]').collect{|player_html| player_html["href"]} + club_names = league_html.xpath('//*[@id="yw1"]//table//tr//td[2]//a[1]').collect{|player_html| player_html.text } clubs = Hash[club_names.zip(club_uris)] @@ -32,7 +32,7 @@ def self.fetch_clubs_and_uris_by_league_uri(league_uri) def self.fetch_by_league_uri(league_uri, fetch_clubs = false) puts "fetching league #{league_uri}" - req = self.get("/#{league_uri}", headers: {"User-Agent" => Transfermarkt::USER_AGENT}) + req = self.get("/#{league_uri}", headers: {"User-Agent" => Useragents.rand()}) if req.code != 200 nil else @@ -40,10 +40,10 @@ def self.fetch_by_league_uri(league_uri, fetch_clubs = false) options = {} options[:league_uri] = league_uri - options[:name] = league_html.xpath('//*[@id="wb_seite"]/table/tr[1]/td[2]/h1/text()').text.strip.gsub(" -","") - options[:country] = league_html.xpath('//*[@id="wb_seite"]/table/tr[1]/td[2]/h1/a').text + options[:name] = league_html.xpath('//select[@id="wettbewerb_select_breadcrumb"]//option[@selected="selected"]')[0].text + options[:country] = league_html.xpath('//select[@id="land_select_breadcrumb"]//option[@selected="selected"]').text - options[:club_uris] = league_html.xpath('//table[@id="vereine"]//tr//td[2]//a[@class="s10"]').collect{|player_html| player_html["href"]} + options[:club_uris] = league_html.xpath('//*[@id="yw1"]//table//tr//td[2]//a[1]').collect{|player_html| player_html["href"]} puts "Found #{options[:club_uris].count} clubs" options[:clubs] = [] @@ -62,12 +62,12 @@ def self.fetch_by_league_uri(league_uri, fetch_clubs = false) def self.fetch_league_uris root_uri = "/en/ligat-haal/startseite/wettbewerb_ISR1.html" - req = self.get("/#{root_uri}", headers: {"User-Agent" => Transfermarkt::USER_AGENT}) + req = self.get("/#{root_uri}", headers: {"User-Agent" => UserAgents.rand()}) if req.code != 200 nil else root_html = Nokogiri::HTML(req.parsed_response) - league_uris = root_html.xpath('//*[@id="categorymenu"]/li/ul/li/a').collect{|league| league["href"]} + league_uris = root_html.xpath('//*[@id="yw1"]//table//tr//td[2]//a[1]').collect{|player_html| player_html["href"]} end end end diff --git a/lib/transfermarkt/live_game.rb b/lib/transfermarkt/live_game.rb index 75c7f31..eb53070 100644 --- a/lib/transfermarkt/live_game.rb +++ b/lib/transfermarkt/live_game.rb @@ -5,7 +5,7 @@ class LiveGame URL = "http://www.transfermarkt.com/en/livescores-und-livetabellen/uebersicht/livescores.html" def self.fetch - req = self.get(URL, headers: {"User-Agent" => Transfermarkt::USER_AGENT}) + req = self.get(URL, headers: {"User-Agent" => UserAgents.rand()}) if req.code != 200 nil else diff --git a/lib/transfermarkt/player.rb b/lib/transfermarkt/player.rb index c9bd15c..7cf1cad 100644 --- a/lib/transfermarkt/player.rb +++ b/lib/transfermarkt/player.rb @@ -33,7 +33,7 @@ def initialize(options = {}) def self.fetch_by_profile_uri(profile_uri = "") puts "fetching player profile #{profile_uri}" - req = self.get("/#{profile_uri}", headers: {"User-Agent" => Transfermarkt::USER_AGENT}) + req = self.get("/#{profile_uri}", headers: {"User-Agent" => UserAgents.rand()}) if req.code != 200 nil else @@ -89,7 +89,7 @@ def self.fetch_by_profile_uri(profile_uri = "") private def self.fetch_performance_data(performance_uri, is_goalkeeper = false) puts "Fetching Performance page for #{performance_uri}" - req = self.get("/#{performance_uri}", headers: {"User-Agent" => Transfermarkt::USER_AGENT}) + req = self.get("/#{performance_uri}", headers: {"User-Agent" => UserAgents.rand()}) if req.code != 200 nil else @@ -116,7 +116,7 @@ def self.fetch_performance_data(performance_uri, is_goalkeeper = false) end def self.fetch_injuries_data(injury_uri) - req = self.get("/#{injury_uri}", headers: {"User-Agent" => Transfermarkt::USER_AGENT}) + req = self.get("/#{injury_uri}", headers: {"User-Agent" => UserAgents.rand()}) if req.code != 200 [] else diff --git a/spec/static_htmls/premier_league_html.html b/spec/static_htmls/premier_league_html.html new file mode 100644 index 0000000..61fe181 --- /dev/null +++ b/spec/static_htmls/premier_league_html.html @@ -0,0 +1,3694 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Transfermarkt + + + + + + +
+
+ + + + + + + +
+
+
+
+ +
+ + + +
+
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ Premier League
+
+
+ + England +
+
+
+
+
+ Premier League
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
League ranking: + 1. league - England England
League size: + 20 teams
Number of players: + 525
Legionaries: + 349 Player(s)  66.48%
ø-Market value: + 6,00 Mill. £
+
+
+ + + + + + + + + + + + + + + + + + + + + +
UEFA coefficient: + 2.Platz  64.392 Punkte
Record champion: + Manchester United  20 mal
ø-Age: + 26,1 Jahre
Defending champions: + Manchester City
Most valuable players: + Luis Suárez  45,76 Mill. £
+
+
+
+ Total market value:
3,15 Bill. £
+
+
+
+
+
+ +
+
+
+
+
+

Info

+
+
+
+
+ Competition startpage
+
+
+
+
+ + + + + + + + +
Select season: +
+ +
+
+ +
+
+
+
+
+
+
+
Clubs Premier League 14/15
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ClubnameSquadAgeTotal market valueø Market value
  52526,1 Years3,15 Bill. £6,00 Mill. £
Chelsea FC3425,2482,86 Mill. £14,20 Mill. £
Manchester City2927,0429,70 Mill. £14,82 Mill. £
Manchester United3125,3368,10 Mill. £11,87 Mill. £
Arsenal FC2725,5311,61 Mill. £11,54 Mill. £
Liverpool FC2926,1278,08 Mill. £9,59 Mill. £
Tottenham Hotspur3025,9253,31 Mill. £8,44 Mill. £
Newcastle United3125,8137,72 Mill. £4,44 Mill. £
Swansea City2727,0109,30 Mill. £4,05 Mill. £
Everton FC2127,9102,08 Mill. £4,86 Mill. £
Stoke City2927,491,39 Mill. £3,15 Mill. £
Southampton FC2225,488,04 Mill. £4,00 Mill. £
Aston Villa2926,088,00 Mill. £3,03 Mill. £
West Ham United2627,983,34 Mill. £3,21 Mill. £
Sunderland AFC2426,071,15 Mill. £2,96 Mill. £
Hull City2427,456,67 Mill. £2,36 Mill. £
West Bromwich Albion1728,156,10 Mill. £3,30 Mill. £
Queens Park Rangers2428,247,83 Mill. £1,99 Mill. £
Crystal Palace2727,344,88 Mill. £1,66 Mill. £
Leicester City2626,326,36 Mill. £1,01 Mill. £
Burnley FC1827,720,06 Mill. £1,11 Mill. £
+ +
+
+ + +
+
+ +
Games of 1.matchday Premier League 14/15
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DateTimeHome teamResultVisiting team
+ Sat + Aug 16, 2014 + + - + + Chelsea FC
+ + + + + + Tottenham Hotspur
+ + + + + + Sunderland AFC
+ + + + + + Aston Villa
+ + + + + + Hull City
+ + + + + + Manchester City
+ + + + + + Swansea City
+ + + + + + Southampton FC
+ + + + + + Everton FC
+ + + + + + Crystal Palace
+
+ +
+
+
+ +
+ +
+
+ + + +
+
+
+ +
+

Relevant news

+
+
+ +
+ +
+
+

The most recent transfers

+

+ +

+
+
+
    +
  • +
    +
    + Ellis Plummer
    +
    + +
    + Age: 19 Years  + England
    + Position: Centre Back
    + Market value: -
    +
    +
    + Transfer fee: Loan +
    +
    +
    + Manchester City
    +
    +   +
    +
    + St. Mirren FC
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Dean Moxey
    +
    + +
    + Age: 28 Years  + England
    + Position: Left-Back
    + Market value: 880 Th. £
    +
    +
    + Transfer fee: Free transfer +
    +
    +
    + Crystal Palace
    +
    +   +
    +
    + Bolton Wanderers
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Aaron Wilbraham
    +
    + +
    + Age: 34 Years  + England
    + Position: Centre Forward
    + Market value: 220 Th. £
    +
    +
    + Transfer fee: Free transfer +
    +
    +
    + Crystal Palace
    +
    +   +
    +
    + Bristol City
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Vanja Milinković-Savić
    +
    + +
    + Age: 17 Years  + Serbia
    + Position: Keeper
    + Market value: -
    +
    +
    + Transfer fee: Loan +
    +
    +
    + Manchester United
    +
    +   +
    +
    + FK Vojvodina
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Matthew Gilks
    +
    + +
    + Age: 32 Years  + Scottland
    + Position: Keeper
    + Market value: 616 Th. £
    +
    +
    + Transfer fee: Free transfer +
    +
    +
    + Blackpool FC
    +
    +   +
    +
    + Burnley FC
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Marvin Emnes
    +
    + +
    + Age: 26 Years  + Netherlands
    + Position: Centre Forward
    + Market value: 1,32 Mill. £
    +
    +
    + Transfer fee: 1,50 Mill. £ +
    +
    +
    + Middlesbrough FC
    +
    +   +
    +
    + Swansea City
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Daniel Alfei
    +
    + +
    + Age: 22 Years  + Wales
    + Position: Right-Back
    + Market value: -
    +
    +
    + Transfer fee: Loan +
    +
    +
    + Swansea City
    +
    +   +
    +
    + Northampton Town
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Adam Lallana
    +
    + +
    + Age: 26 Years  + England
    + Position: Left Midfield
    + Market value: 6,60 Mill. £
    +
    +
    + Transfer fee: 27,28 Mill. £ +
    +
    +
    + Southampton FC
    +
    +   +
    +
    + Liverpool FC
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Jordan Laidler
    +
    + +
    + Age: 19 Years  + England
    + Position: Centre Forward
    + Market value: -
    +
    +
    + Transfer fee: Free transfer +
    +
    +
    + Sunderland AFC
    +
    +   +
    +
    + Unknown
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Diego Costa
    +
    + +
    + Age: 25 Years  + Spain
    + Position: Centre Forward
    + Market value: 30,80 Mill. £
    +
    +
    + Transfer fee: 33,44 Mill. £ +
    +
    +
    + Atlético Madrid
    +
    +   +
    +
    + Chelsea FC
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Siem de Jong
    +
    + +
    + Age: 25 Years  + Netherlands
    + Position: Attacking Midfield
    + Market value: 8,80 Mill. £
    +
    +
    + Transfer fee: 7,66 Mill. £ +
    +
    +
    + AFC Ajax Amsterdam
    +
    +   +
    +
    + Newcastle United
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Romain Amalfitano
    +
    + +
    + Age: 24 Years  + France
    + Position: Attacking Midfield
    + Market value: 880 Th. £
    +
    +
    + Transfer fee: Free transfer +
    +
    +
    + Newcastle United
    +
    +   +
    +
    + FCO Dijon
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Luke Shaw
    +
    + +
    + Age: 18 Years  + England
    + Position: Left-Back
    + Market value: 11,44 Mill. £
    +
    +
    + Transfer fee: 33,00 Mill. £ +
    +
    +
    + Southampton FC
    +
    +   +
    +
    + Manchester United
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Andy Johnson
    +
    + +
    + Age: 33 Years  + England
    + Position: Centre Forward
    + Market value: 880 Th. £
    +
    +
    + Transfer fee: Free transfer +
    +
    +
    + Queens Park Rangers
    +
    +   +
    +
    + Unknown
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Michael Kightly
    +
    + +
    + Age: 28 Years  + England
    + Position: Right Wing
    + Market value: 2,38 Mill. £
    +
    +
    + Transfer fee: ? +
    +
    +
    + Stoke City
    +
    +   +
    +
    + Burnley FC
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Micah Evans
    +
    + +
    + Age: 21 Years  + England
    + Position: Centre Forward
    + Market value: -
    +
    +
    + Transfer fee: Free transfer +
    +
    +
    + Burnley FC
    +
    +   +
    +
    + Unknown
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Bafetimbi Gomis
    +
    + +
    + Age: 28 Years  + France
    + Position: Centre Forward
    + Market value: 8,80 Mill. £
    +
    +
    + Transfer fee: Free transfer +
    +
    +
    + Olympique Lyon
    +
    +   +
    +
    + Swansea City
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Stephen Kingsley
    +
    + +
    + Age: 19 Years  + Scottland
    + Position: Left-Back
    + Market value: 176 Th. £
    +
    +
    + Transfer fee: ? +
    +
    +
    + Falkirk FC
    +
    +   +
    +
    + Swansea City
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Robert Snodgrass
    +
    + +
    + Age: 26 Years  + Scottland
    + Position: Right Wing
    + Market value: 4,84 Mill. £
    +
    +
    + Transfer fee: 6,60 Mill. £ +
    +
    +
    + Norwich City
    +
    +   +
    +
    + Hull City
    +
    +
    +
    +
    +
  • +
  • +
    +
    + Joe Dudgeon
    +
    + +
    + Age: 23 Years  + Northern Ireland
    + Position: Left-Back
    + Market value: 440 Th. £
    +
    +
    + Transfer fee: Free transfer +
    +
    +
    + Hull City
    +
    +   +
    +
    + Unknown
    +
    +
    +
    +
    +
  • + +
+
+ +
+
+

The league's most valuable players

+
+
+
+
+ + + + + + + + + + + + + + + + + +
#Player(s)ClubMarket value
1
Luis Suárez
Centre Forward
Liverpool FC
2
Mesut Özil
Attacking Midfield
Arsenal FC
3
Cesc Fàbregas
Attacking Midfield
Chelsea FC
4
Kun Agüero
Centre Forward
Manchester City
5
Eden Hazard
Left Wing
Chelsea FC
+ +
+
+
+
+
+
Table Premier League 14/15
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#ClubMatches+/-Pnt.
Arsenal FC---
Aston Villa---
Burnley FC---
Chelsea FC---
Crystal Palace---
Everton FC---
Hull City---
Leicester City---
Liverpool FC---
Manchester City---
Manchester United---
Newcastle United---
Queens Park Rangers---
Southampton FC---
Stoke City---
Sunderland AFC---
Swansea City---
Tottenham Hotspur---
West Bromwich Albion---
West Ham United---
+
+ +
+
+
+

Top rumours

+

+ +

+
+
+
    +
  • +
    +
    + Diego Costa
    +
    + +
    + Age: 25 Years  + Spain
    + Position: Centre Forward
    + Market value: 30,80 Mill. £
    +
    +
    +
    + Atlético Madrid
    +
    +   +
    +
    + Chelsea FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Luke Shaw
    +
    + +
    + Age: 18 Years  + England
    + Position: Left-Back
    + Market value: 11,44 Mill. £
    +
    +
    +
    + Southampton FC
    +
    +   +
    +
    + Manchester United
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Emre Can
    +
    + +
    + Age: 20 Years  + Germany
    + Position: Defensive Midfield
    + Market value: 6,60 Mill. £
    +
    +
    +
    + Bayer 04 Leverkusen
    +
    +   +
    +
    + Liverpool FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Emre Can
    +
    + +
    + Age: 20 Years  + Germany
    + Position: Defensive Midfield
    + Market value: 6,60 Mill. £
    +
    +
    +
    + Bayer 04 Leverkusen
    +
    +   +
    +
    + Liverpool FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Demba Ba
    +
    + +
    + Age: 29 Years  + Senegal
    + Position: Centre Forward
    + Market value: 9,68 Mill. £
    +
    +
    +
    + Chelsea FC
    +
    +   +
    +
    + Everton FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Adam Lallana
    +
    + +
    + Age: 26 Years  + England
    + Position: Left Midfield
    + Market value: 6,60 Mill. £
    +
    +
    +
    + Southampton FC
    +
    +   +
    +
    + Liverpool FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Luuk de Jong
    +
    + +
    + Age: 23 Years  + Netherlands
    + Position: Centre Forward
    + Market value: 6,60 Mill. £
    +
    +
    +
    + Borussia Mönchengladbach
    +
    +   +
    +
    + Newcastle United
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Luis Suárez
    +
    + +
    + Age: 27 Years  + Uruguay
    + Position: Centre Forward
    + Market value: 45,76 Mill. £
    +
    +
    +
    + Liverpool FC
    +
    +   +
    +
    + Real Madrid
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Mario Mandzukic
    +
    + +
    + Age: 28 Years  + Croatia
    + Position: Centre Forward
    + Market value: 26,40 Mill. £
    +
    +
    +
    + Bayern Munich
    +
    +   +
    +
    + Chelsea FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Mario Mandzukic
    +
    + +
    + Age: 28 Years  + Croatia
    + Position: Centre Forward
    + Market value: 26,40 Mill. £
    +
    +
    +
    + Bayern Munich
    +
    +   +
    +
    + Chelsea FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Thomas Vermaelen
    +
    + +
    + Age: 28 Years  + Belgium
    + Position: Centre Back
    + Market value: 12,32 Mill. £
    +
    +
    +
    + Arsenal FC
    +
    +   +
    +
    + SSC Napoli
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Mohamed Diamé
    +
    + +
    + Age: 27 Years  + Senegal
    + Position: Central Midfield
    + Market value: 6,16 Mill. £
    +
    +
    +
    + West Ham United
    +
    +   +
    +
    + Everton FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Pierre-Michel Lasogga
    +
    + +
    + Age: 22 Years  + Germany
    + Position: Centre Forward
    + Market value: 7,92 Mill. £
    +
    +
    +
    + Hamburger SV
    +
    +   +
    +
    + Newcastle United
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Pierre-Michel Lasogga
    +
    + +
    + Age: 22 Years  + Germany
    + Position: Centre Forward
    + Market value: 7,92 Mill. £
    +
    +
    +
    + Hamburger SV
    +
    +   +
    +
    + Newcastle United
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Valentin Stocker
    +
    + +
    + Age: 25 Years  + Switzerland
    + Position: Left Wing
    + Market value: 6,16 Mill. £
    +
    +
    +
    + FC Basel 1893
    +
    +   +
    +
    + Newcastle United
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Filipe
    +
    +
    + Filipe
    +
    + Age: 28 Years  + Brazil
    + Position: Left-Back
    + Market value: 13,20 Mill. £
    +
    +
    +
    + Atlético Madrid
    +
    +   +
    +
    + Chelsea FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Shinji Kagawa
    +
    + +
    + Age: 25 Years  + Japan
    + Position: Attacking Midfield
    + Market value: 14,96 Mill. £
    +
    +
    +
    + Manchester United
    +
    +   +
    +
    + Borussia Dortmund
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Shinji Kagawa
    +
    + +
    + Age: 25 Years  + Japan
    + Position: Attacking Midfield
    + Market value: 14,96 Mill. £
    +
    +
    +
    + Manchester United
    +
    +   +
    +
    + Borussia Dortmund
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Jonathan Tah
    +
    + +
    + Age: 18 Years  + Germany
    + Position: Centre Back
    + Market value: 5,72 Mill. £
    +
    +
    +
    + Hamburger SV
    +
    +   +
    +
    + Liverpool FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Jonathan Tah
    +
    + +
    + Age: 18 Years  + Germany
    + Position: Centre Back
    + Market value: 5,72 Mill. £
    +
    +
    +
    + Hamburger SV
    +
    +   +
    +
    + Liverpool FC
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Hatem Ben Arfa
    +
    + +
    + Age: 27 Years  + France
    + Position: Right Wing
    + Market value: 10,56 Mill. £
    +
    +
    +
    + Newcastle United
    +
    +   +
    +
    + AS Roma
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Sebastian Larsson
    +
    + +
    + Age: 29 Years  + Sweden
    + Position: Right Midfield
    + Market value: 4,40 Mill. £
    +
    +
    +
    + Sunderland AFC
    +
    +   +
    +
    + Borussia Mönchengladbach
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Sebastian Larsson
    +
    + +
    + Age: 29 Years  + Sweden
    + Position: Right Midfield
    + Market value: 4,40 Mill. £
    +
    +
    +
    + Sunderland AFC
    +
    +   +
    +
    + Borussia Mönchengladbach
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Toni Kroos
    +
    + +
    + Age: 24 Years  + Germany
    + Position: Attacking Midfield
    + Market value: 35,20 Mill. £
    +
    +
    +
    + Bayern Munich
    +
    +   +
    +
    + Manchester United
    +
    +
    +
    +
    +
    + +
  • +
  • +
    +
    + Toni Kroos
    +
    + +
    + Age: 24 Years  + Germany
    + Position: Attacking Midfield
    + Market value: 35,20 Mill. £
    +
    +
    +
    + Bayern Munich
    +
    +   +
    +
    + Manchester United
    +
    +
    +
    +
    +
    + +
  • + +
+
+ +
+ +
+ + + +
+
+
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spec/units/league_spec.rb b/spec/units/league_spec.rb new file mode 100644 index 0000000..ac12116 --- /dev/null +++ b/spec/units/league_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe Transfermarkt::League do + before(:all) do + FakeWeb.register_uri(:get, "http://www.transfermarkt.co.uk/jumplist/startseite/wettbewerb/GB1", body: File.read(File.join("spec", "static_htmls", "premier_league_html.html")), status: ["200", "OK"]) + @permier_league = Transfermarkt::League.fetch_clubs_and_uris_by_league_uri("/jumplist/startseite/wettbewerb/GB1") + end + + describe '#name' do + it "should be premier league" do + expect(@permier_league.name).to eq("Premier League") + end + end + + describe '#country' do + it "should be england" do + expect(@permier_league.country).to eq("England") + end + end + + describe "#fetch_clubs_and_uris_by_league_uri" do + it "should fetch 20 teams" do + expect(@permier_league.clubs_index.count).to eq(20) + end + end +end \ No newline at end of file diff --git a/transfermarkt.gemspec b/transfermarkt.gemspec index 5d9c1df..57d65ed 100644 --- a/transfermarkt.gemspec +++ b/transfermarkt.gemspec @@ -24,4 +24,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'fakeweb' spec.add_dependency "httparty" spec.add_dependency "nokogiri" + spec.add_dependency "useragents" end