Windows XP で Python 2.7.3 を使用しています Pyscripter 2.5.3.0 を使用しています
次のテストコードを使用して、美しいスープを実行しようとしています
import urllib2
from bs4 import BeautifulSoup
page = urllib2.urlopen("http://www.google.com")
soup = BeautifulSoup(page)
print soup.prettify()
コードは で停止しdammit.py
ます。エラーは次のとおりです。
Message File Name Line Position
Traceback
<module> D:\Python\TestBS.py 19
<module> C:\Python27\lib\site-packages\bs4\__init__.py 29
<module> C:\Python27\lib\site-packages\bs4\builder\__init__.py 4
<module> C:\Python27\lib\site-packages\bs4\element.py 5
<module> C:\Python27\lib\site-packages\bs4\dammit.py 49
EntitySubstitution C:\Python27\lib\site-packages\bs4\dammit.py 70
_populate_class_variables C:\Python27\lib\site-packages\bs4\dammit.py 57
NameError: global name 'codepoint2name' is not defined
コードのこの部分で
class EntitySubstitution(object):
"""Substitute XML or HTML entities for the corresponding characters."""
def _populate_class_variables():
lookup = {}
reverse_lookup = {}
characters_for_re = []
for codepoint, name in list(codepoint2name.items()):