Skip to content

Instantly share code, notes, and snippets.

@chrishaid
Created May 6, 2016 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrishaid/894d5e98e8fc2ce4a41e4eb6b86689c3 to your computer and use it in GitHub Desktop.
Save chrishaid/894d5e98e8fc2ce4a41e4eb6b86689c3 to your computer and use it in GitHub Desktop.
Logging into Think Through Math in R
require(rvest)
require(httr)
# user login url
url <- 'https://lms.thinkthroughmath.com'
# makes TTM think were are a current flavor of Chrome
uastring<-"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
# This is safari if you want ot take that for a spin
#uastring <- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"
# Start session
ttm <- html_session(url, user_agent(uastring))
ttm2<-ttm %>%
html_node("form") %>% #find the login form's html
html_form() %>% # register the form
set_values('user[username]' = 'your user name',
'user[password]' = 'your password') %>% # set credentials needed for from
submit_form(ttm, . ) # submit that badbow
# navigate to dashboard
dashb <-jump_to(ttm, "https://lms.thinkthroughmath.com/dashboard")
# check out response
dashb$url
dashb$html
dashb$response
# Jump to overview (you'll want to change the URL here to match your districts info
overview <-jump_to(ttm, "https://lms.thinkthroughmath.com/reports/overview_report?print=true#page=1&classroom=890372&id=890372&type=classroom&group=student&district=1649&district_name=KIPP+Chicago&school=18286&school_name=KIPP+Create+College+Prep&classroom_name=8th+Mathematics+-+3+-+4(A)&rows_per_page=10000")
# The overview selected at the class level has a table of results that you should be able to pull. Alas, I've not been sucessful at this
# the response seems to be missing all the data that fills in the table, probably because of some javascrip call back to the server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment