You are more flexible with find and to get what you want you just need to run: node = p. Find('div', text="Content I Want") But since it might not be how you want to get there, following options might suit you better: xml = """ContentContent I Want""" from BeautifulSoup import BeautifulSoup p = BeautifulSoup(xml) # returns a list of texts print p.div.div.findNextSibling().div. Contents # returns a list of texts print p.div.div.findNextSibling().
Div(text=True) # join (and strip) the values print ''. Join(s.strip() for s in p.div.div.findNextSibling(). Div(text=True)).
You are more flexible with find, and to get what you want you just need to run: node = p. Find('div', text="Content I Want") But since it might not be how you want to get there, following options might suit you better: xml = """ContentContent I Want""" from BeautifulSoup import BeautifulSoup p = BeautifulSoup(xml) # returns a list of texts print p.div.div.findNextSibling().div. Contents # returns a list of texts print p.div.div.findNextSibling().
Div(text=True) # join (and strip) the values print ''. Join(s.strip() for s in p.div.div.findNextSibling(). Div(text=True)).
I'm reading up on BeautifulSoup to screen-scrape some pretty heavy html pages. Going through the documentation of BeautifulSoup I can't seem to find a easy way to select child elements. I want a easy way to to get the "Content I Want" given I have the object top.
Coming to BeautifulSoup I thought it would be easy, and something like topobj. Instead I only see variables and functions that also return the elements together with text nodes, comments and so on. Am I missing something?
Or do I really need to resort to a long form using .find() or even worse using list comphrensions on the . The reason is that I don't trust the whitespace of the webpage to be the same so I want to ignore it and only traverse on elements.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.