Unable to Correctly Parse `:has()` Pseudo-Classes with More than a Singular Child
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start at the GenericTranslator().css_to_xpath entry point and reproduce the three :has() examples from the issue. Trace how :has() arguments are parsed, especially attribute selectors and descendant selectors. Done means these arguments translate successfully while the existing singular-tag and combinator cases continue to work.
索引モデルが issue の本文から書いたものです。
説明
Issue
When attempting to parse a CSS selector using a :has pseudo-class, it works but only if a singular tag name is provided.
For example, if selecting for a child with attributes:
>>> from cssselect import GenericTranslator
>>> GenericTranslator().css_to_xpath('h4.my-class:has(a[href^="/rel"])')
*** cssselect.parser.SelectorSyntaxError: Expected an argument, got <DELIM '[' at 17>
Likewise, if attempting to select for a tag with a descendant tag, we get:
>>> GenericTranslator().css_to_xpath('h4.my-class:has(div a')
*** cssselect.parser.SelectorSyntaxError: Expected an argument, got <IDENT 'a' at 20>
However, selecting for a singular tag name works:
>>> GenericTranslator().css_to_xpath('h4.my-class:has(a)')
"descendant-or-self::h4[(@class and contains(concat(' ', normalize-space(@class), ' '), ' my-class ')) and (descendant::a)]"
Diagnosing it further, this also does not affect combinators inside the :has(...):
>>> GenericTranslator().css_to_xpath('h4.my-class:has(> a)')
"descendant-or-self::h4[(@class and contains(concat(' ', normalize-space(@class), ' '), ' my-class ')) and (./a)]"
Information
Running cssselect version 1.5.0.
- 主要言語
- Python
- スター
- 311
- フォーク
- 73
- 平均マージ
- 2日 24分
- マージ済み PR(30日)
- 11
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
scrapy/cssselect のほかの issue
-
Add comprehensive developer docs対応中かも @AdrianAtZyte が 62 日前に担当しました。 オープンdocumentation enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
メンテナーはふだん 1 日以内に返信
-
The parsing of :where and :is is not spec compliant対応中かも @AdrianAtZyte が 76 日前に担当しました。 オープンCSS Selectors Level 4 enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
scrapy/cssselect#135 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Support :nth-child(An+B of S)対応中かも @annbgn が 1927 日前に担当しました。 オープンCSS Selectors Level 4
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
scrapy/cssselect#76 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[feature-request] `:not()` to support generic selectors (not only "simple" ones)対応中かも @AdrianAtZyte が 76 日前に担当しました。 オープンCSS Selectors Level 4
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
scrapy/cssselect#51 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
scrapy/cssselect の issue をすべて見る
似ている issue
-
good first issue priority: low size: XS testing
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
cubrid-lab/cubrid-mcp-server#385 ·
メンテナーはふだん 1 日以内に返信
-
good first issue priority: low size: S testing
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
cubrid-lab/cubrid-cookbook-python#447 ·
メンテナーはふだん 1 日以内に返信
-
Python Pointcloudオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ArduCAM/Arducam_tof_camera#125 ·
-
area:curator enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
CassioDalla/Scrinalia#150 ·
メンテナーはふだん 1 日以内に返信
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100