Giter Club home page Giter Club logo

flashscorescraping's Introduction

logo

Technologies   |    Scraping   |    Statistics   |    Documentation


screen

🛠️ Technologies

▶️ How to use

To run my example you have to download chromedriver compatible with your chrome version.

You can use others driver following the Selenium docs.

For the example, we use FlashscoreScraping as a lib.

To start, we created a directory named flashscore-scraping-example.

mkdir flashscore-scraping-example
cd ./flashscore-scraping-example

Within this directory, we have to clone this repository.

git clone https://github.com/gustavofariaa/FlashscoreScraping.git

After clone this repository, we have to install the dependencies.

cd ./FlashscoreScraping
pip install -r requirements.txt
cd ..

🤖 Scraping

To Scraping data we have to create a main.py at the root of the directory.

from FlashscoreScraping import Scraping
from selenium import webdriver

# Scraping startup
scraping = Scraping()

# Selenium startup
driver = webdriver.Chrome('chromedriver')

# get all matches of Brazilian Championship Serie A 2019
scraping.collect(driver, 'brazil', 'serie-a', 2019)

# get all LaLiga matches from 2012 until 2019
scraping.collect(driver, 'spain', 'laliga', 2018, 2012)

driver.quit()

It is important that you have to download chromedriver compatible with your chrome version and that it is in the root directory.

Finally we run the FlashscoreScraping run the command.

python main.py

⚽ Statistics

To get specific statistics of a team, you can import Statistics as a lib in main.py, just like we did before with Scraping.

from FlashscoreScraping import Statistics

# Statistics startup
statistics = Statistics()

# get all matches where the Atletico MG win in 2018
statistics.get_win_matches('brazil', 'serie-a', 'Atletico-MG', 2018)

# get all matches where the Atletico MG lost between 2014 and 2016
statistics.get_lose_matches('brazil', 'serie-a', 'Atletico-MG', 2016, 2014)

# get all matches where the Atletico MG draw in 2015
statistics.get_draw_matches('brazil', 'serie-a', 'Atletico-MG', 2015)

# get all possession ball of Bayern Munich in 2019
statistics.get_statistic_by_team('germany', 'bundesliga', 'Bayern Munich', statistic, 2017)

# get all the names of teams that participated in the Premier League in 2019
statistics.get_teams('england', 'premier-league', 2013)

📚 Documentation

Parameters

  • path: by default, the path is initialized with './data', but the path can be changed to your preferred path.

  • driver: Selenium driver

  • country: country name where the championship is held

  • championship: championship name

  • team: team name

  • statistic: one this statistics

        ============================== STATISTICS ===============================
        "ball_possession",  "goal_attempts", "shots_on_goal", "shots_off_goal", 
        "blocked_shots",    "free_kicks",    "corner_kicks",  "offsides", 
        "total_passes",     "fouls",         "yellow_cards",  "goalkeeper_saves", 
        "completed_passes", "tackles",       "attacks",       "dangerous_attacks" 
        =========================================================================
  • last_year: championship year

  • first_year: required only if you need matches within a given time interval

Scraping

  • instantiate object Scraping
    Scraping(path)
  • start collect flashscore data
    scraping.collect(driver, country, championship, last_year, first_year)

Statistics

  • instantiate object Statistics

    Statistics(path)
  • get all the names of the teams that participated in a championship

    statistics.get_teams(country, championship, last_year, first_year)
  • get all matches where the specified team win in a championship

    statistics.get_win_matches(country, championship, team, last_year, first_year)
  • get all matches where the specified team lose in a championship

    statistics.get_lose_matches(country, championship, team, last_year, first_year)
  • get all matches where the specified team draw in a championship

    statistics.get_draw_matches(country, championship, team, last_year, first_year)
  • get specified statistic from one team in a championship

    statistics.get_statistic_by_team(country, championship, team, statistic, last_year, first_year)



Twitter Linkedin

flashscorescraping's People

Contributors

gustavofariaa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.