HTML:
<div class="someclass">
<h3>First</h3>
<strong>Second</strong>
<hr>
Third
<br>
Fourth
<br>
<em></em>
...
</div>
From above div
node I want to get all child text nodes after hr
("Third"
, "Fourth"
, ... and there might be more)
If I do
document.querySelectorAll('div.someclass>hr~*')
I get NodeList [ br, br, em, ... ]
- no text nodes
With below
document.querySelector('div.someclass').textContent
I get all text nodes as single string
I can get each text node as
var third = document.querySelector('div.someclass').childNodes[6].textContent
var fourth = document.querySelector('div.someclass').childNodes[8].textContent
so I tried
document.querySelector('div.someclass').childNodes[5:] # SyntaxError
and slice()
document.querySelector('div.someclass').childNodes.slice(5) # TypeError
So is there any way I can get all child text nodes starting from hr
node?
UPDATE
I forgot to mention that this question is about web-scraping, but not web-development... I cannot change HTML source code
` tags and they will also be returned?
– messerbill Feb 09 '18 at 12:11