【问题】
折腾:
期间,用如下代码:> retHtml
> parsedHtml = htmlParse(retHtml, asText=TRUE,encoding="GBK")
Error: could not find function "htmlParse"
结果出错:Error: could not find function "htmlParse"
如图:
【解决过程】
1.本来打算参考之前的:
去安装库的,但是发现,不知道htmlParse属于哪个库。
2.后来是搜:
R语言 htmlParse
而找到:
而想到是XML库的。
所以再去安装一下XML库。
3.代码:> install.packages("XML")
trying URL 'http://mirrors.ustc.edu.cn/CRAN/bin/windows/contrib/3.0/XML_3.98-1.1.zip'
Content type 'application/zip' length 4288136 bytes (4.1 Mb)
opened URL
downloaded 4.1 Mb
package ‘XML’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\CLi\AppData\Local\Temp\RtmpIRchyS\downloaded_packages
>
如图:
4.然后再试试之前的代码:
结果还是不行:> parsedHtml = htmlParse(retHtml, asText=TRUE,encoding="GBK")
Error: could not find function "htmlParse"
5.想起来参考别人代码要先去导入此库,然后再运行就可以了:> require("XML")
Loading required package: XML
> parsedHtml = htmlParse(retHtml, asText=TRUE,encoding="GBK")
如图:
【总结】
1.htmlParse是R语言中的XML库中的函数。
2.使用函数之前,需要导入对应的库,写法是:require("XML")