Showing posts with label football. Show all posts
Showing posts with label football. Show all posts

11.15.2014

How to download data from dynamic web pages using R. Example.

How to download data from dynamic web pages using R. Example.

How to download data from dynamic web pages using R. Example.

Here I will describe how I managed to download some nice tables from soccerway.com site. Mainly, I was interested in downloading tables like the one on this page: http://int.soccerway.com/teams/england/southampton-fc/670/squad/

My first try was not very complicated. I simply used XML::readHTMLTable. The function I created, takes the url of the page with table and returns a tidy dataframe. The first line of the function code is for reading a table from the url given, and all the other lines are for making downloaded table tidier. And if you are familiar with R, a single look on the data right after they have been read from the site would be enough to understand what code you should add. There are some problems with reading letters with diacritics, but I will not discuss it in this post.