web scraping - how to get specific text after a div with xpath -
i trouble specific texts located between 2 tags. mean, want text after em tag. want this.
, text after p tag. want this.
. there way of doing that? in advance.
<article> <h1 id='h1'>heading 1</h1> <img src='mypath/pictures/pic.jpg'></img> <p></p> <div id='div1'> <time datetime='2016'>2016</time> </div> <br></br> <em>my location, tn, united states</em> text after em tag. want this. <p></p> text after p tag. want this. <div id='div2'> </div> </article>
you can following sibling texts using
following-sibling::text()
so em after text
//em/following-sibling::text()[1]
the same p tag, , join them
string-join(em/following-sibling::text()[1] | p/following-sibling::text()[1] , ',')
i hope help!
Comments
Post a Comment