问题描述
你好 我在下面执行此python代码
#!/usr/bin/python
print "Content-Type: text/html\n\n";
print "<html><head>";
print "<title>CGI Test</title>";
print "</head><body>";
print "<p>Test page using Python</p>";
print "</body></html>";
import requests
from bs4 import BeautifulSoup
import sys
url='https://kelponton.fr'
page = requests.get(url)
soup = BeautifulSoup(page.content,'html.parser')
print(soup.prettify())
“使用Python的测试页”显示得很好,意味着python正在运行 但是当我有行print(soup.prettify())时,日志中出现以下错误(似乎处理程序未正确安装某些内容?) 我的网站在Apache / Centos7和Plesk上运行 谢谢你的帮助
--------------------------------------
2020-09-14 22:21:12 Error 82.229.61.242 500 GET /admin_sohapply/webscrapp/test5.py HTTP/1.0 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/85.0.4183.102 Safari/537.36 2.01 K Accès SSL/TLS Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: Traceback (most recent call last): Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib64/python2.7/site-packages/mod_python/apache.py",line 398,in HandlerDispatch\n result = obj(req) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib64/python2.7/site-packages/mod_python/cgihandler.py",line 96,in handler\n imp.load_module(module_name,fd,path,desc) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/var/www/vhosts/bibelotandco.fr/httpdocs/admin_sohapply/webscrapp/test5.py",line 16,in <module>\n page = requests.get(url) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/api.py",line 68,in get\n return request('get',url,**kwargs) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/api.py",line 50,in request\n response = session.request(method=method,url=url,**kwargs) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/sessions.py",line 472,in request\n prep = self.prepare_request(req) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/sessions.py",line 403,in prepare_request\n hooks=merge_hooks(request.hooks,self.hooks),Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/models.py",line 304,in prepare\n self.prepare_url(url,params) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/models.py",line 342,in prepare_url\n url = url.decode('utf8') Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib64/python2.7/encodings/utf_8.py",in decode\n return codecs.utf_8_decode(input,errors,True) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: AttributeError: 'NoneType' object has no attribute 'utf_8_decode'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)