終於做出一個POST網頁的例子,抓取高鐵時刻表
library(RCurl)
library(XML)
##輸入相關查詢Value
url = "https://www.thsrc.com.tw/tw/TimeTable/SearchResult"
html = postForm(url,StartStation = "977abb69-413a-4ccf-a109-0272c24fd490" ##台北站ID
,EndStation = "e6e26e66-7dc1-458f-b2f3-71ce65fdc95f" ##板橋站ID
,SearchDate = "2016/07/07"
,SearchTime = "11:00"
,SearchWay = "DepartureInMandarin") ##出發
html_code = htmlParse(html)
##擷取查詢結果
thrsc_id = xpathSApply(test, "//*[@class='column1']",xmlValue)
thrsc_leave_time = xpathSApply(test, "//*[@class='column3']",xmlValue)
thrsc_arrival_time = xpathSApply(test, "//*[@class='column3']",xmlValue)
沒有留言:
張貼留言