Answer the question
In order to leave comments, you need to log in
How to write a css selector "paragraphs going between two headings"?
I understand that the question sounds strange, but I need it for the Scrapy parser, so I cannot add any classes to the elements myself. You need to select all paragraphs between two h2 tags. How to do it right? If you do something like response.css('h2:contains("Story") + p').get() , then only the first paragraph after the h2 heading with the text "Story" will be selected. How to select all paragraphs (their number is arbitrary) until the next h2, and not just the first one? Here is an html example:
<h2>Рассказ</h2>
<p>Привет, Вася!</p>
<p>Как дела?</p>
<h2>О чем рассказ</h2>
<p>Я поздоровался с Васей</p>
<p>Привет, Вася!</p>
<p>Как дела?</p>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question