Golang 網絡爬蟲框架gocolly/colly 二 jQuery selector

Golang 網絡爬蟲框架gocolly/colly 二 jQuery selector

colly框架依賴goquery庫,goquery將jQuery的語法和特性引入到了go語言中。若是要靈活自如地採集數據,首先要了解jQuery選擇器。如下內容是翻譯jQuery官方網站css

《Category: Selectors》章節內容:node

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.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

 

Also in: Selectors > Basic網絡

All Selector (「*」)

Selects all elements.框架

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

選擇所要元素ide

: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.

Also in: Selectors > Form

複選框選擇器

選擇全部複選框

: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」.

Also in: Selectors > Basic

選擇由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.

Also in: Selectors > Form

後代選擇器 (「ancestor descendant」)

選擇指定祖先的全部後代元素

:disabled Selector

Selects all elements that are disabled.

Also in: Selectors > Basic

選擇全部被禁用的元素。

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).

Also in: Selectors > Form

空選擇器

選擇全部沒有子項的元素(包括文本節點)

: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.

Also in: Selectors > Basic

選擇全部隱藏的元素

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.

Also in: Selectors > Basic

多屬性選擇器

符合全部指定屬性過濾器的匹配元素集。

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.

選擇全部可見元素。

相關文章
相關標籤/搜索