GithubHelp home page GithubHelp logo

chess_scrape's Introduction

Summary

This is a small side project in which I scrape all of my games on chess.com to get deeper stats like "What are my average number of moves per game in which I win and which I lose?", "What percent of the time do I win by timeout vs. win by checkmate. Does this percentage change as my ELO does?", "What day of the week do I play the most chess?" etc...

Sidenote: My ELO is a work in progress.

Scrape

First the scraper starts by logging into the site. It enters my username and password and clicks login.

screen shot 2019-01-30 at 10 19 43 pm

Next, it navigates to the archive of every game I've played stored in a table shown below. I scrape the boxed data on the page, and iterate through every page in my history. In additon to that, it also grabs the link for every individual game, which I will then use to grab even more detials.

screen shot 2019-01-30 at 10 27 07 pm

At this point I have a very clean dataframe with the date, link, moves, and result of every game I've played (below)

screen shot 2019-01-30 at 10 35 10 pm

The next step is to iterate through the "Link" column and actually go into every individual chess game to get even more details. The individual games look like the screenshot below. On this page I scrape:

  1. The name, elo, and country of the top player (red)
  2. How the game concluded (timeout, resignation, checkmate, draw...) and the time of the game (purple)
  3. The name, elo, and country of the bottom player (blue)

Originally I ran the scrape assuming I was always the bottom player because that's how it always appears to me on the site's interface. However, on the backend it's totally random who is the top player and who is the bottom player so I had to apply some logic to make sure the data flowed in properly from the scrape.

screen shot 2019-01-30 at 10 43 53 pm

And the result is a datafrae that looks like the one shown below. I concatenate this to the previous dataframe to get my full dataset on my chess games.

screen shot 2019-01-30 at 10 51 50 pm

Questions to Answer

"What is my "real" peak elo? (after it normalizes)"

Discarding the first few games where my elo artificially spiked to 1100+, my peak elo is 1074

screen shot 2019-02-12 at 10 59 27 pm

"What day of the week do I play the most chess?"

Not surprisingly, I play the most chess on the weekends

screen shot 2019-02-12 at 10 51 44 pm

"What countries have I played against? Which is the strongest, which is the weakest?"

Countries I've played the most

screen shot 2019-02-12 at 9 21 56 pm

Those with the highest average elo

screen shot 2019-02-12 at 10 29 13 pm

Those with the lowest average elo

screen shot 2019-02-12 at 10 29 25 pm

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.