colly框架依赖goquery库,goquery将jQuery的语法和特性引入到了go语言中。若是要灵活自如地采集数据,首先要了解jQuery选择器。如下内容是翻译jQuery官方网站css
《Category: Selectors》章节内容:node
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.jquery
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.git
类别:选择器github
从CSS 1-3借用,而后添加它本身的,jQuery提供了一套强大的工具来匹配文档中的一组元素。要使用任何元字符(如 !"#$%&'()*+,./:;<=>?@[\]^`{|}~ )做为名称的文字部分,例如,一个id =“foo.bar”的元素能够使用选择符$("#foo\\.bar")。W3C CSS规范包含了关于有效的CSS选择器的完整规则。Mathias Bynens的关于标识符CSS字符转义序列的博文也是颇有用的。api
Selects all elements.框架
Also in: Selectors > Basic Filter | Selectors > jQuery Extensionsless
选择所要元素ide
Select all elements that are in the progress of an animation at the time the selector is run.
Also in: Selectors > Attribute
选择全部动画元素
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 (-).
Also in: Selectors > Attribute
属性包含前缀选择器 [name|=”value”]
选择具备指定属性的元素,其值等于给定的字符串,或者以该字符串开头,后跟连字符( - )。
Selects elements that have the specified attribute with a value containing a given substring.
Also in: Selectors > Attribute
属性包含选择器 [name*=”value”]
选择具备指定属性的元素,其值包含给定子字符串。
Selects elements that have the specified attribute with a value containing a given word, delimited by spaces.
Also in: Selectors > Attribute
属性包含字选择器[name~=”value”]
选择具备指定属性的元素,其值包含由空格分隔的给定单词。
Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.
Also in: Selectors > Attribute
属性结束选择器[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.
Also in: Selectors > Attribute
属性不等于选择器[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
属性以开始选择器[name^=”value”]
选择具备指定属性的元素,其值的开始部分与给定字符串彻底一致。
Selects all button elements and elements of type button.
Also in: Selectors > Form | Selectors > jQuery Extensions
按钮选择器
选择全部按钮元素和类型按钮的元素。
Selects all elements of type checkbox.
复选框选择器
选择全部复选框
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”.
选择由“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.
后代选择器 (“ancestor descendant”)
选择指定祖先的全部后代元素
Selects all elements that are disabled.
选择全部被禁用的元素。
Selects all elements with the given tag name.
Also in: Selectors > Content Filter
元素选择器
选择指定标签名的全部元素
Select all elements that have no children (including text nodes).
空选择器
选择全部没有子项的元素(包括文本节点)
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
选择偶数元素,下标从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.
Also in: Selectors > Attribute
选择匹配集中全部索引大于指定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.
选择全部隐藏的元素
Selects a single element with the given id attribute.
Also in: Selectors > Form | Selectors > jQuery Extensions
选择具备给定id属性的单个元素。
Selects all elements of type image.
Also in: Selectors > Form | Selectors > jQuery Extensions
选择全部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.
Also in: Selectors > Attribute
在匹配集中选择全部索引小于给定值的元素。
Matches elements that match all of the specified attribute filters.
多属性选择器
符合全部指定属性过滤器的匹配元素集。
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
选择至少有一个孩子节点(元素或文本)的全部元素
Selects all elements of type password.
Also in: Selectors > Form | Selectors > jQuery Extensions
选择全部password类型的元素。
Selects all elements of type radio.
Also in: Selectors > Form | Selectors > jQuery Extensions
选择全部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
选择文档的根节点元素。
Selects all elements that are selected.
Also in: Selectors > Form | Selectors > jQuery Extensions
选择全部选中的元素。
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
选择由文档的URI的片断标识符指示的目标元素。
Selects all input elements of type text.
Also in: Selectors > jQuery Extensions | Selectors > Visibility Filter
选择全部text类型的input元素
Selects all elements that are visible.
选择全部可见元素。