2016-03-03 90 views
2

我试图提取自动从这个site。一旦电力报价我设定的邮编(即:300),我可以下载(手动)的PDF文件提取结果

我使用httr包:

library(httr) 
qr<- POST("http://www.qenergy.com.au/What-Are-Your-Options", 
    query=list(postcode=3000)) 
res <- htmlParse(content(qr)) 

的问题是,该文件的URL不在查询响应。请任何帮助。

回答

2

试试这个

library(httr) 
qr<- POST("http://www.qenergy.com.au/What-Are-Your-Options", 
      encode="form", 
      body=list(postcode=3000)) 
res <- content(qr) 
pdfs <- as(res['//a[contains(@href, "pdf")]/@href'], "character") 
head(pdfs) 
# [1] "flux-content/qenergy/pdf/VIC price fact sheet jemena distribution zone business/Jemena-Freedom-Biz-5-Day-Time-of-Use-A210.pdf" 
# [2] "flux-content/qenergy/pdf/VIC price fact sheet jemena distribution zone business/Jemena-Freedom-Biz-7-Day-Time-of-Use-A250.pdf" 
# [3] "flux-content/qenergy/pdf/VIC price fact sheet jemena distribution zone business/Jemena-Freedom-Biz-Single-Rate-CL.pdf"   
# [4] "flux-content/qenergy/pdf/VIC price fact sheet jemena distribution zone business/Jemena-Freedom-Biz-Single-Rate.pdf"    
# [5] "flux-content/qenergy/pdf/VIC price fact sheet united energy distribution zone business/United-Freedom-Biz-5-Day-Time-of-Use.pdf" 
# [6] "flux-content/qenergy/pdf/VIC price fact sheet united energy distribution zone business/United-Freedom-Biz-7-Day-Time-of-Use.pdf"