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.
選擇全部可見元素。