fork download
  1. # 载入rvest包
  2. library(xml2)
  3. library(rvest)
  4.  
  5. url <- 'https://w...content-available-to-author-only...h.com/pc/tw'
  6. Session <- html_session(url)
  7.  
  8. ## 找有 <input submit> 的 list
  9. Form <- html_form(Session)[[1]]
  10. Fields <- Form$fields
  11.  
  12.  
  13. ## ------------------------------------------------
  14. ## 為何不用set_value?
  15. ## 因為成人、小孩、嬰兒那邊沒有list name -.-
  16.  
  17. ## 出發地
  18. Fields$inputFrom$value = "TPE"
  19.  
  20. ## 目的地
  21. Fields$name$value = "OKA"
  22.  
  23. ## 去的日期
  24. Fields$departingon$value = "2018/09/12"
  25.  
  26. ## 回來日期
  27. Fields$returningon$value = "2018/09/20"
  28.  
  29. ## 成人數量
  30. Fields[[7]]$value = "2"
  31.  
  32. ## 小孩數量
  33. Fields[[8]]$value = "0"
  34.  
  35. ## 嬰兒數量
  36. Fields[[9]]$value = "0"
  37.  
  38. ## ------------------------------------------------
  39.  
  40. Fields
  41.  
  42. ## 但是看起來怪怪的-.-
  43. submit_form(Session,Form)
Success #stdin #stdout #stderr 0.22s 183680KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error in library(xml2) : there is no package called ‘xml2’
Execution halted