BeautifulSoup バージョン 3 と 4 の両方でこれをテストしました。コードは BS4 で動作するため、バージョン 3 を使用している必要があります。
>>> from bs4 import BeautifulSoup as BS4 # Version 4
>>> from BeautifulSoup import BeautifulSoup as BS3 # Version 3
>>> bs3soup = BS3("""<table cellspacing="0" cellpadding="4">
...
... stuff
...
... </table>""")
>>> bs4soup = BS4("""<table cellspacing="0" cellpadding="4">
...
... stuff
...
... </table>""")
>>> bs3soup.find('table', cellpadding = 4, cellspacing = 0) # None
>>> bs4soup.find('table', cellpadding = 4, cellspacing = 0)
<table cellpadding="4" cellspacing="0">
stuff
</table>
したがって、BS3 を引き続き使用する場合は、次の手順で修正します。
>>> soup.find('table', cellpaddin="4", cellspacing="0") # Notice how the integers are now strings, like in the HTML.
ただし、バージョン 4 ( ) を使用する必要がありますfrom bs4 import BeautifulSoup
。