Say I have a structure like that;
<div id="body">
<h1> Title </h1>
<p> Date Created </p>
<p class="text-bold"> Description </p>
<p> Para1 </p>
<p> Para2 </p>
<p> Para..</p>
<p> ParaN </p>
I am trying to get Para1 to ParaN appended together. To add onto it, Para1 in certain links might be placed as //p[5]
and sometimes as //p[6]
.
So by running a default of,
def parse_details(self, response):
item = response.meta["item"]
item['Message'] = response.xpath('//p[x]/text()').extract()
yield item
It will sometimes fail and return a wrong field as x
is somewhat dynamic. What stays constant is that I need all fields under <p class="text-bold"> Description </p>
.
Is there anyway to do it?