BeautifulSoup 在服务器和笔记本电脑上给出不同的结果
BeautifulSoup giving different results on server and laptop
我在服务器 (Ubuntu 14.04.2 LTS) 和笔记本电脑 (Ubuntu 15.04) 上有一段代码 运行,结果不同。
我正在使用相同的 html 文件构建汤(我自己将其复制到服务器)
temp = open('temp.html', 'r')
soup = bs4.BeautifulSoup(temp.read())
table = soup.find('table')
if not table:
return []
rows = table.find_all('tr')
print len(rows)
服务器打印:2
而在本地它打印:7
更多信息:
服务器:
- Python 2.7.6
- beautifulsoup4 4.3.2
- 点 7.0.3
本地:
- Python 2.7.9
- beautifulsoup4 4.3.2
- 1.5.6 点
我错过了什么?我还应该寻找什么?
我的服务器没有安装 lxml,而本地安装了 lxml 3.4.4。在服务器上安装它解决了问题
我在服务器 (Ubuntu 14.04.2 LTS) 和笔记本电脑 (Ubuntu 15.04) 上有一段代码 运行,结果不同。 我正在使用相同的 html 文件构建汤(我自己将其复制到服务器)
temp = open('temp.html', 'r')
soup = bs4.BeautifulSoup(temp.read())
table = soup.find('table')
if not table:
return []
rows = table.find_all('tr')
print len(rows)
服务器打印:2
而在本地它打印:7
更多信息:
服务器:
- Python 2.7.6
- beautifulsoup4 4.3.2
- 点 7.0.3
本地:
- Python 2.7.9
- beautifulsoup4 4.3.2
- 1.5.6 点
我错过了什么?我还应该寻找什么?
我的服务器没有安装 lxml,而本地安装了 lxml 3.4.4。在服务器上安装它解决了问题