htmlの文字列があるとします...
<div class="content">
This is some test <b>this is bold </b> this is great list of text.
</div>
<div class="content">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>
ここで、Scrapy を使用して、これら 2 つの要素の内容を 1 つの変数にスクレイピングしたいと考えています。
def parse(self, response):
hxs = HtmlXPathSelector(response)
# this returns all nested elements/nodes except text
contents = product.select('//div[@class="content"]/*').extract()
# this returns all nested text except elements/nodes
contents = product.select('//div[@class="content"]/text()').extract()
両方の要素/ノードのネストされた HTML 全体を変数の文字列として取得するにはどうすればよいですか?