File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,18 @@ pseudo-elements::
120
120
>>> selector.css('title::text').get()
121
121
'Example website'
122
122
123
+ To extract all text of one or more element and all their child elements,
124
+ formatted as plain text taking into account HTML tags (e.g. ``<br/> `` is
125
+ translated as a line break), set ``text=True `` in your call to
126
+ :meth: `~Selector.get ` or :meth: `~Selector.getall ` instead of including
127
+ ``::text `` (CSS) or ``/text() `` (XPath) in your query:
128
+
129
+ >>> selector.css(' #images' ).get(text = True )
130
+ 'Name: My image 1\nName: My image 2\nName: My image 3\nName: My image 4\nName: My image 5'
131
+
132
+ See :meth: `Selector.get ` for additional parameters that you can use to change
133
+ how the extracted plain text is formatted.
134
+
123
135
As you can see, ``.xpath() `` and ``.css() `` methods return a
124
136
:class: `~parsel.selector.SelectorList ` instance, which is a list of new
125
137
selectors. This API can be used for quickly selecting nested data::
You can’t perform that action at this time.
0 commit comments