Просто, чтобы доказать вам, что ваш случай является уникальным и не имеет ничего общего с Redhat.
Я вытащил экземпляр микро-Redhat из AWS, и вот полный процесс из SSH в новые машины Redhat.
(1) Здесь я установил beautifulsoup4 на новой машине:
$ ssh -i key.pem [email protected]
The authenticity of host 'awsip' cant be established.
RSA key fingerprint is ....
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'awsip' (RSA) to the list of known hosts.
[[email protected] ~]$ sudo easy_install beautifulsoup4
Searching for beautifulsoup4
Reading http://pypi.python.org/simple/beautifulsoup4/
...
Installed /usr/lib/python2.6/site-packages/beautifulsoup4-4.3.2-py2.6.egg
Processing dependencies for beautifulsoup4
Finished processing dependencies for beautifulsoup4
(2) Я открыл питона и получить выход из Google как в html
и soup
[[email protected] ~]$ python
Python 2.6.6 (r266:84292, May 27 2013, 05:35:12)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2
>>> from bs4 import BeautifulSoup
>>> html = urllib2.urlopen("http://www.google.com").read()
>>> soup = BeautifulSoup(html)
>>> print html[:100]
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage"><head><meta content="Search t
>>> print soup.prettify()[:100]
<!DOCTYPE html>
<html itemscope="" itemtype="http://schema.org/WebPage">
<head>
<meta content="Se
Для отладки это ошибка urllib2 или bs4: попробуйте запустить этот код:
from bs4 import BeautifulSoup
html = """
<html>
<head>
</head>
<body>
<div id="1">numberone</div>
<div id="2">numbertwo</div>
</body>
</html>
"""
print BeautifulSoup(html).find('div', {"id":"1"})
Если BeautifulSoup успешно установлено, вы получите ожидаемый результат, как показано ниже:
<div id="1">numberone</div>
хорошо, каковы различия между локальной машиной и на сервере? – bchhun
Насколько я понял ваш вопрос, на обеих машинах html читается нормально, но на вашем локальном компьютере вы получаете некоторый вывод из bs4, а на сервере ничего не получается. Вы получаете «Нет» или пустую строку? –
Локальный работает под управлением windows, python 2.7. Сервер работает redhat python 2.7 – Darthyogurt