[R] how to write html output (webscraped using RCurl package) into file?
Milan Bouchet-Valat
nalimilan at club.fr
Sat Apr 21 22:08:11 CEST 2012
Le samedi 21 avril 2012 à 07:05 -0700, sagarnikam123 a écrit :
> i want
> "http://scop.berkeley.edu/astral/pdbstyle/?id=d1fjgc2&output=html",showing
> information in webpage to be written in .txt file as it is(i don't want any
> html tag)
> i am using "RCurl" package
>
> >marathi<-htmlTreeParse("http://scop.berkeley.edu/astral/pdbstyle/?id=d1fjgc2&output=html")
> >marathi
> >kasam<-marathi$children$html[["body"]][["pre"]][["text"]]
> >kasam
> > write(kasam,"papita.txt")
> Error in cat(list(...), file, sep, fill, labels, append) :
> argument 1 (type 'list') cannot be handled by 'cat
>
> i want to write kasam, as shown on console into .txt file
kasam is a list, not a character string:
> str(kasam)
Named list()
- attr(*, "class")= chr [1:5] "XMLTextNode" "XMLNode"
"RXMLAbstractNode" "XMLAbstractNode" ...
You need to convert it to a character vector first:
write(xmlValue(kasam), "papita.txt")
Regards
More information about the R-help
mailing list