Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selector text doc #248

Merged
merged 3 commits into from
Nov 13, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ pseudo-elements::
>>> selector.css('title::text').get()
'Example website'

Extract text witout ::text
==========================
Gallaecio marked this conversation as resolved.
Show resolved Hide resolved
You can extract inner text without specifying ``::text`` in your selctor instead
an optional paramter text=True in the ``get()`` or ``getall()`` methods.
Gallaecio marked this conversation as resolved.
Show resolved Hide resolved

>>> selector.css('title').get(text=True)
Gallaecio marked this conversation as resolved.
Show resolved Hide resolved

You can pass additional paramter ``guess_punct_space``, ``guess_layout`` and ``guess_layout``

As you can see, ``.xpath()`` and ``.css()`` methods return a
:class:`~parsel.selector.SelectorList` instance, which is a list of new
selectors. This API can be used for quickly selecting nested data::
Expand Down