I use R to parse html code, and I would like to know the most efficient way to sparse the following code :
<script type="text/javascript">
var utag_data = {
environnement : "prod",
device : getDevice(),
displaytype : getDisplay($(window).innerWidth()),
pagename : "adview",
pagetype : "annonce"}</script>
I started to do this:
infos = unlist(xpathApply(page,
'//script[@type="text/javascript"]',
xmlValue))
infos=gsub('\n| ','',infos)
infos=gsub("var utag_data = ","",infos)
fromJSON(infos)
And the code above returns somthing really weird:
$nvironnemen
[1] "prod"
$evic
NULL
$isplaytyp
NULL
$agenam
[1] "adview" etc.
I would like to know how to do it very efficient way: how to parse directly the data list in the javascript ? Thank you.
NULLfor keys device and displaytyp?