所以我正在慢慢地学习Python,并试图制作一个简单的函数,它将从在线游戏的高分页面中绘制数据。这是别人的代码,我重写了一个函数(这可能是问题),但我得到这个错误。代码如下:
>>> from urllib2 import urlopen
>>> from BeautifulSoup import BeautifulSoup
>>> def create(el):
source = urlopen(el).read()
soup = BeautifulSoup(source)
get_table = soup.find('table', {'id':'mini_player'})
get_rows = get_table.findAll('tr')
text = ''.join(get_rows.findAll(text=True))
data = text.strip()
return data
>>> create('http://hiscore.runescape.com/hiscorepersonal.ws?user1=bigdrizzle13')
Traceback (most recent call last):
File "", line 1, in
create('http://hiscore.runescape.com/hiscorepersonal.ws?user1=bigdrizzle13')
File "", line 6, in create
text = ''.join(get_rows.findAll(text=True))
AttributeError: 'ResultSet' object has no attribute 'findAll'提前致谢。