I would like to import the data (table) from this website: http://dr.ittf.com/ittf_ranking/ittf_team_ranking.html

I don't know how to import and automatically change the date/year. Let's say, I want to import the table of several months in 2015, for example.

Thank you.


1 Answer 1


The first step is to identify URL to the data source. Inspecting the source code of the website, we find that the website consists of two iframes. The URL to leftmost iframe is


This is the URL to the table. The next step is to identify the parameters from the URL so that we can easily build the URL corresponding to the table which we want to scrape:

url[gender_, month_, year_] := URLBuild[
  "http://dr.ittf.com/ittf_ranking/team_ranking1.asp", {
   "FormName" -> "Search",
   "FormAction" -> "search",
   "Gender" -> gender,
   "Month1" -> month,
   "Year1" -> year,
   "Category" -> "sen"

url["M", 6, 2017]

(* Out: "http://dr.ittf.com/ittf_ranking/team_ranking1.asp?FormName=Search&\
FormAction=search&Gender=M&Month1=6&Year1=2017&Category=sen" *)

Now we need to import the HTML into Mathematica and extract the information. This is traditionally done by importing the HTML as XML, and then using Cases to find the information. There are plenty of examples of that already in other questions. I will use my package, jsoupLink, to do the parsing. With jsoupLink it would look like this:

html = Import[url["M", 6, 2017], "HTMLDOM"];
rows = html["Select", "tr"][[7 ;;]];
columns = #["AllText"] & /@ #["Select", "td"][[{2, 4, 5}]] & /@ rows;
columns[[;; 10]] // TableForm

Mathematica graphics

  • 1
    $\begingroup$ I can't say more, but you are my HERO! How do you have a good knowledge about HTML parsing like that? wow! upvote for your kindness! $\endgroup$
    – Nam Nguyen
    Jun 13, 2017 at 8:57
  • $\begingroup$ @ERT I used to do a bit of web development. I'm glad it helped. $\endgroup$
    – C. E.
    Jun 14, 2017 at 0:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.