简体   繁体   中英

Import Data from Web Exportable Spreadsheet

I have a sreadsheet that uses a lot of data from fangraphs.com. Here is an example of one of the data sets that I am using:

http://www.fangraphs.com/leaders.aspx?pos=all&stats=bat&lg=all&qual=0&type=0&season=2014&month=0&season1=2013&ind=0&team=0&rost=0&age=0&filter=&players=0

Here is another example:

http://www.fangraphs.com/leaders.aspx?pos=all&stats=bat&lg=all&qual=0&type=0&season=2014&month=13&season1=2013&ind=0&team=0&rost=0&age=0&filter=&players=0

So within my spreadsheet I have a tab that contains the data you get when you select "Export Data" on that website. Currently when I want to update the data I need to go to the site and manually export each spreadsheet and paste them into the tabs of my main sheet.

How can I have the two tabs in my main sheet automaticaly update with the data from those exportable sheets? A friend mentioned that I could use R, so I have it downloaded, but I'm not sure where to begin looking to teach myself how to do this.

Thanks in advance, and please let me know if you need any more details!

You might need to download team per team to ensure that you don't miss some rows in the table: For instance for Angel (=team 1)

library(XML)
x=readHTMLTable(doc = "http://www.fangraphs.com/leaders.aspx?pos=p&stats=bat&lg=all&qual=0&type=0&season=2014&month=0&season1=2013&ind=0&team=1&rost=0&age=0&filter=&players=0")  
x[[33]]

You don't have to learn completely new language ( R in this case) to get the work done.

Basically you are going to write browser automation script (click,wait,fetch data) or "scrap" the web page.

You can write browser automation script in the language you already know, check https://code.google.com/p/selenium-vba

This question also provides some hints: How to download the contents of a paginated Jquery/JS table?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM