python - BeautifulSoup - TypeError: 'NoneType' object is not callable -


I need to make my code backwards compatible with Python 2 and Sunderscape 3. My code was written on Python 2.7 and in this case using BS4 but when I try to run it on Squeeze Server, I get this error (this has Python 2 and BS3):

  Try: Import from BS 4 Import Beautiful Soup: Beautiful Soup Import Beautiful Sunda gmp = Open (FNN, 'R') Soup = Beautiful Soup (GMP) P = Soup.INI.Div. Find_Old ('P') P = Soup. FINDand ('P') Typed: No 'type' object if I change it in:  
  p = soup.body.div.findAll ('p')  I get this error: 

  p = soup.body.div.findAll ('p')  

P> TypeError: 'NoneType' object is not worth the corner

Throwed error update

  file "/ home / user /openerp/7.0/addons/my_module/models/gec.py ", line 401, parse_html_data in p = soup.body.div.findAll ('p') #used Search for previous compatibility for BS3 version instead of find_all All TypeError: 'NoneType' By the way, both approaches work with Python 2 and BS4 on my Ubuntu, but not on the squeeze, there is no other difference in those versions which I do not know / know and gives me this error?   

You are using Sunder 3, but using the beautiful 4 syntax.

Your fallback is here at fault:

  Try: Import from bs4 import Beautiful suits except interrupt: Beautiful soup with import Beautiful  

If you want to use either version 3 or 4, then paste it on version 3 syntax:

  p = soup.body.div.findAll ('P')  

Because find_all is not a valid method in beautiful code 3, so instead of tag search it is interpreted as / Plenty> will respond differently for broken or incomplete HTML used by beautiful soup 3 if you have lxml on Ubuntu, then it will be used as default parser, and It will enter a <<> missing code and for you Beautiful soup 3 can leave it

I firmly urge you to fall back delete , and stay with beautiful version version 4 only . The version has been discontinued 3 years ago, and there are uninterrupted worms in the beautiful soup 4, additional facilities are provided which you want to use.

Beautifully installed in pure virtual environment on any platform supported by Python and Python pure Python. You are tied to the No system-provided package.

For example on Debian Sikuyi, you want to be with Sundasup 3.1.0, and even your problem with findAll is almost certainly the release of that Uses from use.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -