I have some code I have used in the past to count student commits on GitHub (see this blogpost), which worked as of a few months ago. However, in the interim I have enabled two-factor authentication on GitHub. So I'm now running into an issue when I attempt to use rvest to log in to GitHub. Does anyone have demo code of how to get around this? I suspect it is something like
library(rvest)
session <- session("https://github.com/login")
login <- session %>%
html_node("form")%>%
html_form()%>%
html_form_set(login = "YourGitHubUsername", password = "SuperSecureP@ssw0rd")
github <- session %>%
session_submit(login, submit = "commit") %>%
session() %>%
html_node("form") %>%
html_form() %>%
html_form_set(authenticity_token = "2FANUMBERS") %>%
session_submit(login, submit = "submit") %>%
read_html()
although I get an error running this, perhaps because I haven't pre-specified the URL where the login will bring you? If anyone has an example of using rvest with two-factor authentication, please let me know!