go - jQuery 的第 n 个子方法等价于什么?
问题描述
我尝试编写第一个 google go 程序。我得到了这个工作部分:
package main
import (
"fmt"
"os"
"regexp"
"github.com/PuerkitoBio/goquery"
"github.com/gocolly/colly"
)
func TrimSpaceNewlineInString(s string) string {
re := regexp.MustCompile(` +\n+ +\t+`)
return re.ReplaceAllString(s, "")
}
func main() {
args := os.Args[1:]
c := colly.NewCollector()
c.OnHTML("tr",
func(e *colly.HTMLElement) {
ch := e.DOM.Children()
spalte1 := ch.Eq(0)
spalte2 := ch.Eq(1)
spalte1.Each(
func(_ int, s *goquery.Selection) {
fmt.Print(TrimSpaceNewlineInString(s.Text()), ":", TrimSpaceNewlineInString(spalte2.Text()))
})
})
c.Visit("https://deweysearchde.pansoft.de/webdeweysearch/executeSearch.html" +
"?lastScheduleRecord=669.1-669.7&lastTableRecord=&query=" + args[0] + "&_showShortNotations=off&catalogs=DNB&_catalogs=off&catalogs=GBV&_catalogs=off&catalogs=HeBIS&_catalogs=off&catalogs=SUB&_catalogs=off&catalogs=SWB&_catalogs=off&catalogs=FUB&_catalogs=off")
}
但是我只需要得到第二列,如果它在 [0-9.-] 范围内,如果是这样的话,我将需要下面的第三列以及这个 DOM HTMLElement 表的 DDC 分类。我想检索以下内容
600;Technik
660;Chemische Verfahrenstechnik
669;Metallurgie
669.1-669.7;Metallurgie einzelner Metalle und deren Legierungen
669.1;Eisenmetalle
这里的任何人都可以帮助我并告诉我如何使用 colly Colly doc for go来完成,它类似于 jQuery?
PS:我已经尝试过这种方式 - 带孩子。但输出看起来像这样。我不知道为什么。
Notation:Thema :
Haupttafeln
600:
Technik
660:
Chemische Verfahrenstechnik
661:
Industriechemikalien
661.2-661.6:
Säuren, Basen, Salze
661.5:
Ammoniumsalze
Notation:Thema :HilfstafelnT1--0:Hilfstafel 1. StandardschlüsselT2--0:Hilfstafel 2. Geo ...
解决方案
推荐阅读
- spring - Spring-Data-Cassandra SchemaAction 不起作用
- shell - 如何在本机 POSIX shell 脚本中乘以一个字符或字符串?
- excel - Excel VBA .Select 仅适用于表格(1)
- c++ - 如何在 C++ 中使用多个线程对我的系统进行基准测试?
- javascript - 节点js中未处理的承诺拒绝错误
- java - 如何在 for 循环中将此 Java POJO 保存到存储库中?
- datetime - kafka消费者时间戳使用哪个时区以及如何更改它?
- python - Python:在给定形状的情况下创建具有多个维度的数组
- string - Golang 判断字符串是否包含字符串(带通配符)
- c++ - Gtk::Window 添加网格未显示我的子小部件