Facebook
From Buff Peafowl, 3 Years ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 56
  1. my_recursive_func (element) {
  2.  
  3.         var childrenElements = element.getChildren()
  4.         for childElement in childrenElements {
  5.        
  6.                 if (childElement.tag == "p") OR (childElement.tag == "h1") OR (childElement.tag == "h2") {
  7.                         print childElement.text
  8.                 }
  9.                
  10.                 my_recursive_func(childElement)
  11.         }
  12. }
  13.  
  14.  
  15.  
  16. my_recursive_func(soup.getDocumentElement())