在Go中安装exp/html模块。

huangapple go评论157阅读模式
英文:

Install exp/html in Go

问题

看起来Go目前还不支持HTML网页解析工具/包,尽管它已经通过encoding/xml提供了XML抓取功能。那么我该如何在Go中安装exp/html包呢?

据我所知,所有的答案,至少在我进行了10分钟的搜索后遇到的,都没有给出正确的答案;当我尝试运行它们时,我得到了错误信息cannot find package XXX in YYYno Go source files in XXX

所以,目前是否可以在不重新编译和从头设置整个Go环境的情况下安装它?或者我漏掉了什么?

我使用的是OS X 10.8,并运行Go版本1.1,这是我通过OS X软件包安装程序安装的。

供您参考,以下代码没有成功:

go get code.google.com/p/go/src/pkg/exp/html
go get code.google.com/p/go.exp/inotify

谢谢。

英文:

It looks like Go doesn't support HTML web parsing tools/packages yet, despite it already providing XML scraping via encoding/xml. So how can I install exp/html package in Go?

As far as I know, all the answers, at least I stumbled upon on the Web with 10 minutes worth of searching, didn't return the correct answer; when I tried to run those, I got the error cannot find package XXX in YYY or no Go source files in XXX.

So as of now, can I install it without re-compling and setting the whole Go environment from scratch? Or am I missing something?

I'm on OS X 10.8 and run Go version 1.1, which I installed from OS X package installer.

For your information, these code didn't make it.

go get code.google.com/p/go/src/pkg/exp/html
go get code.google.com/p/go.exp/inotify

Thanks.

答案1

得分: 4

我刚刚尝试了:

go get code.google.com/p/go.net/html

看起来好像可以工作。

我有一种感觉它已经从exp库移动到了新的net库。

编辑:文档可浏览的仓库

英文:

I just tried:

go get code.google.com/p/go.net/html

and it seemed to work.

I have a feeling it's been moved from the exp library to the new net library.

EDIT: Documentation & browseable repo.

答案2

得分: 1

在Go 1.4(2014年11月9日)中,您需要输入以下命令:

go get golang.org/x/net/html

参考链接:

英文:

With go 1.4 (November 9th, 2014), you will have to type:

go get golang.org/x/net/html

See:

huangapple
  • 本文由 发表于 2013年9月19日 14:57:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/18888093.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定