R: webscraping a table not showing any data -


i trying webscrape option table:

http://www.cmegroup.com/trading/metals/base/copper_quotes_settlements_options.html

i tried:

library(xml) options.cu<-readhtmltable("http://www.cmegroup.com/trading/metals/base/copper_quotes_settlements_options.html",stringsasfactors = false) options.cu 

but get:

$table_under_bluebar v1 v2 v3 1 trade date type expiration

and no data table. grateful help.

this table dynamically created using javascript. can inspect traffic see if can find feed. doing note following url:

http://www.cmegroup.com/cmews/mvc/xslttransformer.do?xlstdoc=/xslt/da/dailysettlement.xsl 

this takes url parameter denotes product line or such. example:

http://www.cmegroup.com/cmews/mvc/xslttransformer.do?xlstdoc=/xslt/da/dailysettlement.xsl&url=/da/dailysettlement/v1/dsreport/productcode/hx/foi/oof/exchange/xcec/underlying/hg/productid/797 

would table copper options has product id 797. additional parameters can added specifying parameters:

http://www.cmegroup.com/cmews/mvc/xslttransformer.do?xlstdoc=/xslt/da/dailysettlement.xsl&url=/da/dailysettlement/v1/dsreport/productcode/hx/foi/oof/exchange/xcec/underlying/hg/productid/797?tradedate=04/17/2013&monthyear=null&optiontypename=daily&optiontype=ame 

you should able use feed relevant data:

xmld <- "http://www.cmegroup.com/cmews/mvc/xslttransformer.do?xlstdoc=/xslt/da/dailysettlement.xsl&url=/da/dailysettlement/v1/dsreport/productcode/hx/foi/oof/exchange/xcec/underlying/hg/productid/797"  library(xml) options.cu <- readhtmltable(xmld,stringsasfactors = false) str(options.cu) #list of 1 # $ dailysettlementtable:'data.frame':  337 obs. of  10 variables: #  ..$ v1 : chr [1:337] "daily settlements copper american options (final)trade date: 04/18/2013" "strike" "025" "050" ... #  ..$ v2 : chr [1:337] na "type" "call" "call" ... #  ..$ v3 : chr [1:337] na "open" "-" "-" ... #  ..$ v4 : chr [1:337] na "high" "-" "-" ... #  ..$ v5 : chr [1:337] na "low" "-" "-" ... #  ..$ v6 : chr [1:337] na "last" "-" "-" ... #  ..$ v7 : chr [1:337] na "change" "+.0170" "+.0170" ... #  ..$ v8 : chr [1:337] na "settle" "2.9545" "2.7045" ... #  ..$ v9 : chr [1:337] na "estimatedvolume" "-" "-" ... #  ..$ v10: chr [1:337] na "prior dayopen interest" "-" "-" ... 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -