This is my HTML document
<div class='my-class'>
<p>some text</p>
</div>
I want to get the inner HTML of div.my-class element, which is:
<p>some text</p>
The inner html is not always a <p> it could be some other element.
Here is what I have tried but not able to get the desired output:
res = response.css('div.my-class').get();
/* result */
<div class='my-class'>
<p>some text</p>
</div>
//-------------------------------------------
res = response.css('div.my-class::text').get();
/* result */
some text
Here is a way to get the children of the element of class my-class:
html = "<div class='my-class'><p>some text</p></div>"
response = Selector(text=html, type="html")
print(response.xpath('//*[@class="my-class"]/*').get())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With