Skip to content

Instantly share code, notes, and snippets.

@Jian-Qiao
Created August 22, 2017 17:22
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 Jian-Qiao/b1d760d08af480896be754a47bb805a5 to your computer and use it in GitHub Desktop.
Save Jian-Qiao/b1d760d08af480896be754a47bb805a5 to your computer and use it in GitHub Desktop.
Fighters_Scrapped=data.frame()
#Get Fighters' URL
Fighters_URL=sapply(unique(c(as.character(Fights_Scrapped$Fighter1_url),as.character(Fights_Scrapped$Fighter2_url))),function(x) paste('http://sherdog.com',x,sep=''))
for(j in seq(1,length(Fighters_URL))){
Fighter=read_html(Fighters_URL[j])
Result=Fighter %>% html_nodes('strong, .locality, .birthday span,.vcard h1') %>% html_text()
Fighter_got=as.data.frame(t(Result[1:9]))
colnames(Fighter_got)=c('Name','Birth_Date','Age','Birth_Place','Country','Height','Weight','Association','Class')
Fighter_got$Fighter_id=gsub('.*-','',Fighters_URL[j])
Fighters_Scrapped=rbind(Fighters_Scrapped,Fighter_got)
print(j)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment