GoLang语言的应用 之 Demo_Xpath_Go
利用 Xpath 读取 html 内容, 通过 Github 来演示 Xpath 如何使用
更新信息
开发者:沙振宇(沙师弟专栏)
创建时间:2019-12-4
最后一次更新时间:2019-12-5
CSDN博客地址:https://shazhenyu.blog.csdn.net/article/details/103391918
先安装 Github 的其它包
https://github.com/pkg/errors
https://github.com/lestrrat-go/libxml2
去除内容的空格和换行符
str = strings.Replace(str, " ", "", -1) // 去除空格
str = strings.Replace(str, "\n", "", -1) // 去除换行符
运行效果
nodes type: types.NodeList,len: 3
nodes type: *dom.Text,text: WhyGitHub?
nodes type: *dom.Text,text: Explore
nodes type: *dom.Text,text: Pricing