colly框架依赖goquery库,goquery将jQuery的语法和特性引入到了go语言中。如果要灵活自如地采集数据,首先要了解jQuery选择器。以下内容是翻译jQuery官方网站

《Category: Selectors》章节内容:

Borrowing from CSS 1–3, and then adding its own, jQuery offers a powerful set of tools for matching a set of elements in a document.

To use any of the meta-characters ( such as  !"#$%&'()*+,./:;<=>?@[\]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id="foo.bar", can use the selector $("#foo\\.bar"). The W3C CSS specification contains the complete set of rules regarding valid CSS selectors. Also useful is the blog entry by Mathias Bynens on CSS character escape sequences for identifiers.

类别:选择器

从CSS 1-3借用,然后添加它自己的,jQuery提供了一套强大的工具来匹配文档中的一组元素。要使用任何元字符(如 !"#$%&'()*+,./:;<=>?@[\]^`{|}~ )作为名称的文字部分,例如,一个id =“foo.bar”的元素可以使用选择符$("#foo\\.bar")。W3C CSS规范包含了关于有效的CSS选择器的完整规则。Mathias Bynens的关于标识符CSS字符转义序列的博文也是很有用的。

Also in: Selectors > Basic

Selects all elements.

Also in: Selectors > Basic Filter | Selectors > jQuery Extensions

选择所要元素

Select all elements that are in the progress of an animation at the time the selector is run.

选择所有动画元素文章来源地址https://www.yii666.com/article/455263.html

Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-).

属性包含前缀选择器 [name|=”value”]

选择具有指定属性的元素,其值等于给定的字符串,或者以该字符串开头,后跟连字符( - )。

Selects elements that have the specified attribute with a value containing a given substring.

属性包含选择器 [name*=”value”]

选择具有指定属性的元素,其值包含给定子字符串。

Selects elements that have the specified attribute with a value containing a given word, delimited by spaces.

属性包含字选择器[name~=”value”]

选择具有指定属性的元素,其值包含由空格分隔的给定单词。

Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.

属性结束选择器[name$=”value”]

选择具有指定属性的元素,其值以给定字符串结尾,精确匹配。比较区分大小写。

Selects elements that have the specified attribute with a value exactly equal to a certain value.

Also in: Selectors > Attribute | Selectors > jQuery Extensions

属性等于选择器[name=”value”]

选择具有指定属性的元素,其值恰好等于给定值。

Select elements that either don’t have the specified attribute, or do have the specified attribute but not with a certain value.

属性不等于选择器[name!=”value”]

选择不具有指定属性的元素,或者具有指定属性但不具有特定值的元素。

Selects elements that have the specified attribute with a value beginning exactly with a given string.

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

属性以开始选择器[name^=”value”]

选择具有指定属性的元素,其值的开始部分与给定字符串完全一致。

Selects all button elements and elements of type button.

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

按钮选择器

选择所有按钮元素和类型按钮的元素。

Selects all elements of type checkbox.

Also in: Selectors > Form

复选框选择器

选择所有复选框

Matches all elements that are checked or selected.

Also in: Selectors > Hierarchy

匹配所有选中的元素。

Selects all direct child elements specified by “child” of elements specified by “parent”.

Also in: Selectors > Basic

选择由“parent”指定元素的所有直接“child”指定子元素。

Selects all elements with the given class.

Also in: Selectors > Content Filter

选择指定类的所有元素。

Select all elements that contain the specified text.

Also in: Selectors > Hierarchy

选择包含指定文本的所有元素

Selects all elements that are descendants of a given ancestor.

Also in: Selectors > Form

后代选择器 (“ancestor descendant”)

选择指定祖先的所有后代元素

Selects all elements that are disabled.

Also in: Selectors > Basic

选择所有被禁用的元素。

Selects all elements with the given tag name.

Also in: Selectors > Content Filter

元素选择器

选择指定标签名的所有元素

Select all elements that have no children (including text nodes).

Also in: Selectors > Form

空选择器

选择所有没有子项的元素(包括文本节点)

Selects all elements that are enabled.

Also in: Selectors > Basic Filter | Selectors > jQuery Extensions

选择所有启用的元素

Select the element at index n within the matched set.

Also in: Selectors > Basic Filter | Selectors > jQuery Extensions

选择匹配集中index =n的元素(下标从0开始)。

Selects even elements, zero-indexed. See also odd.

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

选择偶数元素,下标从0开始。

Selects all elements of type file.

Also in: Selectors > Child Filter

选择所有文件类型的元素

Selects all elements that are the first child of their parent.

Also in: Selectors > Child Filter

选择所有父节点的第一个孩子元素。

Selects all elements that are the first among siblings of the same element name.

Also in: Selectors > Basic Filter | Selectors > jQuery Extensions

选择同一元素名称的所有兄弟节点中的第一个元素。

Selects the first matched DOM element.

Also in: Selectors > Basic Filter | Selectors > Form

选择第一个匹配的DOM元素。

Selects element if it is currently focused.

Also in: Selectors > Basic Filter | Selectors > jQuery Extensions

选择指定元素,当前处于获取焦点状态

Select all elements at an index greater than index within the matched set.

选择匹配集中所有索引大于指定index值的元素。

Selects elements that have the specified attribute, with any value.

Also in: Selectors > Content Filter | Selectors > jQuery Extensions

选择具有指定属性的所有元素,可以是任何值。

Selects elements which contain at least one element that matches the specified selector.

Also in: Selectors > Basic Filter | Selectors > jQuery Extensions

选择指定元素,其包含至少一个元素匹配给定选择器。

Selects all elements that are headers, like h1, h2, h3 and so on.

Also in: Selectors > jQuery Extensions | Selectors > Visibility Filter

选择所有标题元素,例如h1,h2,h3等

Selects all elements that are hidden.

Also in: Selectors > Basic

选择所有隐藏的元素

Selects a single element with the given id attribute.

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

选择具有给定id属性的单个元素。

Selects all elements of type image.

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

选择所有image类型的元素

Selects all input, textarea, select and button elements.

Also in: Selectors > Basic Filter

选择所有input, textarea, select 和button元素。

Selects all elements of the specified language.

Also in: Selectors > Child Filter

选择所有指定语言的元素。

Selects all elements that are the last child of their parent.

Also in: Selectors > Child Filter

选择所有父元素的最后一个孩子节点元素。

Selects all elements that are the last among siblings of the same element name.

Also in: Selectors > Basic Filter | Selectors > jQuery Extensions

选择同一元素名称的所有兄弟节点中的最后一个元素。

Selects the last matched element.

Also in: Selectors > Basic Filter | Selectors > jQuery Extensions

选择最后一个匹配的元素。

Select all elements at an index less than index within the matched set.

在匹配集中选择所有索引小于给定值的元素。

Matches elements that match all of the specified attribute filters.

Also in: Selectors > Basic

多属性选择器

符合所有指定属性过滤器的匹配元素集。

Selects the combined results of all the specified selectors.

Also in: Selectors > Hierarchy

多重选择器

选择所有指定选择器的组合结果。

Selects all next elements matching “next” that are immediately preceded by a sibling “prev”.

Also in: Selectors > Hierarchy

选择所有下一个匹配“next”的元素,紧接在兄弟“prev”之后。

Selects all sibling elements that follow after the “prev” element, have the same parent, and match the filtering “siblings” selector.

Also in: Selectors > Basic Filter

选择“prev”元素之后的所有同级元素,具有相同的父级,并匹配筛选“siblings”选择器。

Selects all elements that do not match the given selector.

Also in: Selectors > Child Filter

选择不匹配给定选择器的所有元素。

Selects all elements that are the nth-child of their parent.

Also in: Selectors > Child Filter

选择所有父元素的第n个子元素。

Selects all elements that are the nth-child of their parent, counting from the last element to the first.

Also in: Selectors > Child Filter

选择所有父元素的第n个子元素,从后向前计数。

Selects all the elements that are the nth-child of their parent in relation to siblings with the same element name, counting from the last element to the first.

Also in: Selectors > Child Filter

选择父元素的具有相同指定元素名称的子元素中第n个元素,按照从后向前的顺序计数。

Selects all elements that are the nth child of their parent in relation to siblings with the same element name.

Also in: Selectors > Basic Filter | Selectors > jQuery Extensions

选择父元素的具有相同指定元素名称的子元素中第n个元素

Selects odd elements, zero-indexed. See also even.

Also in: Selectors > Child Filter

选择所有奇数元素,下标从0开始。

Selects all elements that are the only child of their parent.

Also in: Selectors > Child Filter

选择所有父元素的唯一孩子元素。

Selects all elements that have no siblings with the same element name.

Also in: Selectors > Content Filter | Selectors > jQuery Extensions

选择没有相同元素名称的兄弟节点的所有元素。

Select all elements that have at least one child node (either an element or text).

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

选择至少有一个孩子节点(元素或文本)的所有元素

Selects all elements of type password.

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

选择所有password类型的元素。

Selects all elements of type radio.

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

选择所有radio类型的元素。

Selects all elements of type reset.

Also in: Selectors > Basic Filter

选择所有reset类型的元素

Selects the element that is the root of the document.

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

选择文档的根节点元素。

Selects all elements that are selected.

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

选择所有选中的元素。

Selects all elements of type submit.

Also in: Selectors > Basic Filter

选择所有submit类型的元素。

Selects the target element indicated by the fragment identifier of the document’s URI.

Also in: Selectors > Form | Selectors > jQuery Extensions文章来源站点https://www.yii666.com/

选择由文档的URI的片段标识符指示的目标元素。

Selects all input elements of type text.

Also in: Selectors > jQuery Extensions | Selectors > Visibility Filter

选择所有text类型的input元素

Selects all elements that are visible.

选择所有可见元素。