Skip to content

Instantly share code, notes, and snippets.

@bryanyang0528
Last active August 29, 2015 14:01
Show Gist options
  • Save bryanyang0528/3cdb38b0326152dbad0f to your computer and use it in GitHub Desktop.
Save bryanyang0528/3cdb38b0326152dbad0f to your computer and use it in GitHub Desktop.
##generate the list of url
#產生空白的list存放欲抓網站的URL
url_list <- list()
#觀察原始網站如"http://lishi.tianqi.com/taibei/201101.html"
#月份'01'、'02'是字串格式,預先製作一個陣列存放
month <- c('01','02','03','04','05','06','07', '08', '09', '10', '11', '12')
#利用迴圈自動產生月份網址
for (year in 2011:2013){
url <- paste('http://lishi.tianqi.com/taibei/',year,month,'.html',sep='')
url_list <- rbind(url_list,url)
}
#將產生的網址去格式化,方便讀取
url_list <- unlist(url_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment