|
楼主 |
发表于 2020-12-5 20:08:55
|
显示全部楼层
情况如下:
soup = bs4.BeautifulSoup(respone.text)
name = [i.text.strip() for i in soup.findAll(name = 'a',attrs = {'data-el':'region'})]##刚才那些乱七八糟的码,不是text信息
type = [i.text.split('|')[0].strip() for i in soup.findAll(name ='div',attrs = {'class':'houseInfo'})]
size = [i.text.split('|')[1].strip()[:-2] for i in soup.findAll(name ='div',attrs = {'class':'houseInfo'})]
dircetion = [i.text.split('|')[2].strip() for i in soup.findAll(name ='div',attrs = {'class':'houseInfo'})]
ZX = [i.text.split('|')[3].strip() for i in soup.findAll(name ='div',attrs = {'class':'houseInfo'})]
floor = [i.text.split('|')[4].strip() for i in soup.findAll(name ='div',attrs = {'class':'houseInfo'})]
year = [i.text.split('|')[5].strip() for i in soup.findAll(name ='div',attrs = {'class':'houseInfo'})]
[float(i.text[:-1]) for i in soup.findAll(name ='div',attrs = {'class':'totalPrice'})]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-39-5bac3378361a> in <module>
7 floor = [i.text.split('|')[4].strip() for i in soup.findAll(name ='div',attrs = {'class':'houseInfo'})]
8 year = [i.text.split('|')[5].strip() for i in soup.findAll(name ='div',attrs = {'class':'houseInfo'})]
----> 9 [float(i.text[:-1]) for i in soup.findAll(name ='div',attrs = {'class':'totalPrice'})]
<ipython-input-39-5bac3378361a> in <listcomp>(.0)
7 floor = [i.text.split('|')[4].strip() for i in soup.findAll(name ='div',attrs = {'class':'houseInfo'})]
8 year = [i.text.split('|')[5].strip() for i in soup.findAll(name ='div',attrs = {'class':'houseInfo'})]
----> 9 [float(i.text[:-1]) for i in soup.findAll(name ='div',attrs = {'class':'totalPrice'})]
TypeError: 'list' object is not callable
|
|