在Python中,我们有urllib2和httplib,但我一直在Go中搜索!页面,我只发现了一个http lib,我不知道这个lib是否相同。是否有类似Python的urllib2的库?
1
A
回答
0
我不知道你在的urllib2寻找什么,因为它有几个特点。但是,我发现这个代码的主要条件:http://play.golang.org/p/Iq91LjcAka
我希望这是你在找什么。我也发现它在谷歌会话的这个话题:https://groups.google.com/forum/#!topic/Golang-Nuts/RnBF9Tlzfqc
0
如果您想要落后于主要的golang http
package,您可以使用像go-metainspector这样的项目。
它与python urllib2类似,它返回页面的元信息,例如标题。
go-metainspector是一个网络抓取工具包,可以访问给定网址的基本信息和元标记。
url := "http://www.cloudcontrol.com/pricing"
MI, err := metainspector.New(url)
if err != nil {
fmt.Printf("Error: %v", err)
} else {
fmt.Printf("\nURL: %s\n", MI.Url())
fmt.Printf("Scheme: %s\n", MI.Scheme())
fmt.Printf("Host: %s\n", MI.Host())
fmt.Printf("Root: %s\n", MI.RootURL())
fmt.Printf("Title: %s\n", MI.Title())
fmt.Printf("Language: %s\n", MI.Language())
fmt.Printf("Author: %s\n", MI.Author())
fmt.Printf("Description: %s\n", MI.Description())
fmt.Printf("Charset: %s\n", MI.Charset())
fmt.Printf("Feed URL: %s\n", MI.Feed())
fmt.Printf("Links: %v\n", MI.Links())
fmt.Printf("Images: %v\n", MI.Images())
fmt.Printf("Keywords: %v\n", MI.Keywords())
fmt.Printf("Compatibility: %v\n", MI.Compatibility())
}
相关问题
- 1. Scala/java是否有类似Python的StringIO?
- 2. Python是否有类似于Java的System.arraycopy?
- 3. 是否有类似Python的枚举linq
- 4. Javascript中是否有类似Python的numpy.apply_along_axis?
- 5. Flex是否有类似于jQuery的库?
- 6. 是否有类似rubygems.org的scala库
- 7. 的Python的urllib2库
- 8. 关于Python的urllib2库,HTTPHandler是什么?
- 9. slf4j中是否有类似org.apache.log4j.EnhancedPatternLayout的类?
- 10. 在QT中是否有类似QListIterator的Python类?
- 11. node.js shell是否具有类似Python类型的命令?
- 12. 是否有类似C++的番石榴类库?
- 13. 是否有一个具有类似git特质的数据库?
- 14. mysql是否有类似autoupdate
- 15. Python是否具有与Java的CountDownLatch类似的控制机制?
- 16. Python/Django - 是否有与Rails的assert_difference类似的断言?
- 17. 在OpenMP中是否有类似于Python的threading.Event的机制?
- 18. 是否有类似于mysql的sqlsrv库的函数mysql_real_escape_string?
- 19. 是否有类似于Java中的pyparsing的库?
- 20. 是否有类似于Java的lxml或nokogiri的库?
- 21. 是否有类似于Android的Three20 Project的库?
- 22. 是否有一个与Python urllib和urllib2等效的Objective-C?
- 23. 是否有类似于PdfReader的WordReader?
- 24. CSS是否有类似jQuery的:has()?
- 25. VS Code是否有类似Atom的addKeystrokeResolver?
- 26. Chrome中是否有globalStorage的类似物?
- 27. 是否有类似'onload`的Ember事件
- 28. 是否有类似$ templateCache的图像?
- 29. C#是否有类似PHP的mb_convert_encoding()?
- 30. Visual Studio是否有类似Borland的CodeGuard?
Go的默认http客户端非常好,你真的不需要别的东西。只是用它! –
已经[在golang-nuts邮件列表中讨论](https://groups.google.com/d/topic/golang-nuts/RnBF9Tlzfqc/discussion)。 – kostix