Golang 網絡爬蟲框架gocolly/colly 二 jQuery selector
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字符轉義序列的博文也是很有用的。
All Selector (“*”)
Selects all elements.
Also in: Selectors > Basic Filter | Selectors > jQuery Extensions
選擇所要元素
:animated Selector
Select all elements that are in the progress of an animation at the time the selector is run.
Also in: Selectors > Attribute
選擇所有動畫元素
Attribute Contains Prefix Selector [name|=”value”]
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”]
選擇具有指定屬性的元素,其值等於給定的字符串,或者以該字符串開頭,后跟連字符( - )。
Attribute Contains Selector [name*=”value”]
Selects elements that have the specified attribute with a value containing a given substring.
Also in: Selectors > Attribute
屬性包含選擇器 [name*=”value”]
選擇具有指定屬性的元素,其值包含給定子字符串。
Attribute Contains Word Selector [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”]
選擇具有指定屬性的元素,其值包含由空格分隔的給定單詞。
Attribute Ends With Selector [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”]
選擇具有指定屬性的元素,其值以給定字符串結尾,精確匹配。比較區分大小寫。
Attribute Equals Selector [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”]
選擇具有指定屬性的元素,其值恰好等於給定值。
Attribute Not Equal Selector [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”]
選擇不具有指定屬性的元素,或者具有指定屬性但不具有特定值的元素。
Attribute Starts With Selector [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”]
選擇具有指定屬性的元素,其值的開始部分與給定字符串完全一致。
:button Selector
Selects all button elements and elements of type button.
Also in: Selectors > Form | Selectors > jQuery Extensions
按鈕選擇器
選擇所有按鈕元素和類型按鈕的元素。
:checkbox Selector
Selects all elements of type checkbox.
復選框選擇器
選擇所有復選框
:checked Selector
Matches all elements that are checked or selected.
Also in: Selectors > Hierarchy
匹配所有選中的元素。
Child Selector (“parent > child”)
Selects all direct child elements specified by “child” of elements specified by “parent”.
選擇由“parent”指定元素的所有直接“child”指定子元素。
Class Selector (“.class”)
Selects all elements with the given class.
Also in: Selectors > Content Filter
選擇指定類的所有元素。
:contains() Selector
Select all elements that contain the specified text.
Also in: Selectors > Hierarchy
選擇包含指定文本的所有元素
Descendant Selector (“ancestor descendant”)
Selects all elements that are descendants of a given ancestor.
后代選擇器 (“ancestor descendant”)
選擇指定祖先的所有后代元素
:disabled Selector
Selects all elements that are disabled.
選擇所有被禁用的元素。
Element Selector (“element”)
Selects all elements with the given tag name.
Also in: Selectors > Content Filter
元素選擇器
選擇指定標簽名的所有元素
:empty Selector
Select all elements that have no children (including text nodes).
空選擇器
選擇所有沒有子項的元素(包括文本節點)
:enabled Selector
Selects all elements that are enabled.
Also in: Selectors > Basic Filter | Selectors > jQuery Extensions
選擇所有啟用的元素
:eq() Selector
Select the element at index n within the matched set.
Also in: Selectors > Basic Filter | Selectors > jQuery Extensions
選擇匹配集中index =n的元素(下標從0開始)。
:even Selector
Selects even elements, zero-indexed. See also odd.
Also in: Selectors > Form | Selectors > jQuery Extensions
選擇偶數元素,下標從0開始。
:file Selector
Selects all elements of type file.
Also in: Selectors > Child Filter
選擇所有文件類型的元素
:first-child Selector
Selects all elements that are the first child of their parent.
Also in: Selectors > Child Filter
選擇所有父節點的第一個孩子元素。
:first-of-type Selector
Selects all elements that are the first among siblings of the same element name.
Also in: Selectors > Basic Filter | Selectors > jQuery Extensions
選擇同一元素名稱的所有兄弟節點中的第一個元素。
:first Selector
Selects the first matched DOM element.
Also in: Selectors > Basic Filter | Selectors > Form
選擇第一個匹配的DOM元素。
:focus Selector
Selects element if it is currently focused.
Also in: Selectors > Basic Filter | Selectors > jQuery Extensions
選擇指定元素,當前處於獲取焦點狀態
:gt() Selector
Select all elements at an index greater than index within the matched set.
Also in: Selectors > Attribute
選擇匹配集中所有索引大於指定index值的元素。
Has Attribute Selector [name]
Selects elements that have the specified attribute, with any value.
Also in: Selectors > Content Filter | Selectors > jQuery Extensions
選擇具有指定屬性的所有元素,可以是任何值。
:has() Selector
Selects elements which contain at least one element that matches the specified selector.
Also in: Selectors > Basic Filter | Selectors > jQuery Extensions
選擇指定元素,其包含至少一個元素匹配給定選擇器。
:header Selector
Selects all elements that are headers, like h1, h2, h3 and so on.
Also in: Selectors > jQuery Extensions | Selectors > Visibility Filter
選擇所有標題元素,例如h1,h2,h3等
:hidden Selector
Selects all elements that are hidden.
選擇所有隱藏的元素
ID Selector (“#id”)
Selects a single element with the given id attribute.
Also in: Selectors > Form | Selectors > jQuery Extensions
選擇具有給定id屬性的單個元素。
:image Selector
Selects all elements of type image.
Also in: Selectors > Form | Selectors > jQuery Extensions
選擇所有image類型的元素
:input Selector
Selects all input, textarea, select and button elements.
Also in: Selectors > Basic Filter
選擇所有input, textarea, select 和button元素。
:lang() Selector
Selects all elements of the specified language.
Also in: Selectors > Child Filter
選擇所有指定語言的元素。
:last-child Selector
Selects all elements that are the last child of their parent.
Also in: Selectors > Child Filter
選擇所有父元素的最后一個孩子節點元素。
:last-of-type Selector
Selects all elements that are the last among siblings of the same element name.
Also in: Selectors > Basic Filter | Selectors > jQuery Extensions
選擇同一元素名稱的所有兄弟節點中的最后一個元素。
:last Selector
Selects the last matched element.
Also in: Selectors > Basic Filter | Selectors > jQuery Extensions
選擇最后一個匹配的元素。
:lt() Selector
Select all elements at an index less than index within the matched set.
Also in: Selectors > Attribute
在匹配集中選擇所有索引小於給定值的元素。
Multiple Attribute Selector [name=”value”][name2=”value2″]
Matches elements that match all of the specified attribute filters.
多屬性選擇器
符合所有指定屬性過濾器的匹配元素集。
Multiple Selector (“selector1, selector2, selectorN”)
Selects the combined results of all the specified selectors.
Also in: Selectors > Hierarchy
多重選擇器
選擇所有指定選擇器的組合結果。
Next Adjacent Selector (“prev + next”)
Selects all next elements matching “next” that are immediately preceded by a sibling “prev”.
Also in: Selectors > Hierarchy
選擇所有下一個匹配“next”的元素,緊接在兄弟“prev”之后。
Next Siblings Selector (“prev ~ siblings”)
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”選擇器。
:not() Selector
Selects all elements that do not match the given selector.
Also in: Selectors > Child Filter
選擇不匹配給定選擇器的所有元素。
:nth-child() Selector
Selects all elements that are the nth-child of their parent.
Also in: Selectors > Child Filter
選擇所有父元素的第n個子元素。
:nth-last-child() Selector
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個子元素,從后向前計數。
:nth-last-of-type() Selector
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個元素,按照從后向前的順序計數。
:nth-of-type() Selector
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個元素
:odd Selector
Selects odd elements, zero-indexed. See also even.
Also in: Selectors > Child Filter
選擇所有奇數元素,下標從0開始。
:only-child Selector
Selects all elements that are the only child of their parent.
Also in: Selectors > Child Filter
選擇所有父元素的唯一孩子元素。
:only-of-type Selector
Selects all elements that have no siblings with the same element name.
Also in: Selectors > Content Filter | Selectors > jQuery Extensions
選擇沒有相同元素名稱的兄弟節點的所有元素。
:parent Selector
Select all elements that have at least one child node (either an element or text).
Also in: Selectors > Form | Selectors > jQuery Extensions
選擇至少有一個孩子節點(元素或文本)的所有元素
:password Selector
Selects all elements of type password.
Also in: Selectors > Form | Selectors > jQuery Extensions
選擇所有password類型的元素。
:radio Selector
Selects all elements of type radio.
Also in: Selectors > Form | Selectors > jQuery Extensions
選擇所有radio類型的元素。
:reset Selector
Selects all elements of type reset.
Also in: Selectors > Basic Filter
選擇所有reset類型的元素
:root Selector
Selects the element that is the root of the document.
Also in: Selectors > Form | Selectors > jQuery Extensions
選擇文檔的根節點元素。
:selected Selector
Selects all elements that are selected.
Also in: Selectors > Form | Selectors > jQuery Extensions
選擇所有選中的元素。
:submit Selector
Selects all elements of type submit.
Also in: Selectors > Basic Filter
選擇所有submit類型的元素。
:target Selector
Selects the target element indicated by the fragment identifier of the document’s URI.
Also in: Selectors > Form | Selectors > jQuery Extensions
選擇由文檔的URI的片段標識符指示的目標元素。
:text Selector
Selects all input elements of type text.
Also in: Selectors > jQuery Extensions | Selectors > Visibility Filter
選擇所有text類型的input元素
:visible Selector
Selects all elements that are visible.
選擇所有可見元素。