首先是宾夕法尼亚州立大学(The Pennsylvania State University缩写PSU)的生信课件下载,这个生信不仅有课件,而且在中国的优酷视频网站里面还有全套授课视频,非常棒!
可以看出所有的课件pdf链接都在这一个页面,所以是非常简单的代码!
下面是R代码:
library(XML)
library(RCurl)
library(dplyr)
psu_edu_url='http://www.personal.psu.edu/iua1/courses/2013-BMMB-597D.html';
wp=getURL(psu_edu_url)
base='http://www.personal.psu.edu/iua1/courses/file';
#pse_edu_links=getHTMLLinks(psu_edu_url)
psu_edu_links=getHTMLLinks(wp)
psu_edu_pdf=psu_edu_links[grepl(".pdf$",psu_edu_links,perl=T)]
for (pdf in psu_edu_pdf){
down_url=getRelativeURL(pdf,base)
filename=last(strsplit(pdf,"/")[[1]])
cat("Now we down the ",filename,"\n")
#pdf_file=getBinaryURL(