同楼主,这个问题我也碰到了。
用html_parser好像不也行
replace也不解决不完全,我希望把所有数据(房间类型,面积,位置,详细位置,发布时间,价格)放一行
最后没办法只能这样了
import requests ##导入requests
from bs4 import BeautifulSoup ##导入bs4中的BeautifulSoup
res = requests.get('http://sz.58.com/nanshan/zufang/0/j2/?minprice=0_1600&PGTID=0d300008-0071-367d-7e8f-38bb92b6eebc&ClickID=2')
res.encoding='utf-8'
soup=BeautifulSoup(res.text,'html.parser')
for info in soup.select('li'):
a=info.select('.des .room')[0].text.replace(" ","")
b=info.select('.des .add')[0].text.replace(" ","")
c=info.select('.listliright .sendTime')[0].text.replace(" ","")
d=info.select('.listliright .money')[0].text
print(a,b,c,d)
print(".....................................................")