VPS上でDjangoとMeCabを用いたスクレイピングプログラムを作成しています。
ローカル環境では問題なく動くのですが,VPS上ではエラーが出ます。
bash
1$ pip3 freeze | grep -e request -e lxml -e beautiful -e html5lib 2beautifulsoup4==4.6.3 3html5lib==1.0.1 4lxml==3.7.3 5request==1.0.2 6requests==2.19.1
のように,必要なパッケージのインストールが確認されているのに,
Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?
というエラーが出ます。
(lxml,html.parserの場合も同様)
python
1models.py 2 3 html = requests.get(searchUrl) 4 bs = BeautifulSoup(html.text, 'html5lib') ... 5 for el in bs.select("h3.r a"): 6 title = el.get_text() 7 url = dict(parse_qsl(urlparse(el.get("href")).query))["q"]
エラーはbs = BeautifulSoup(html.text, 'html5lib')で生じます。
また,直前にhtml.encoding('utf-8')を書き加えた場合にはhtml.encoding('utf-8')でエラーとなります。
どのようにすればエラーが解決できるでしょうか?
なお,stackoverflowやteratailでの同様の質問は参照済みです。
環境はLocal:macOS High Sierra,VPS:CentOS7
いただいた質問に関する出力結果は,
https://docs.google.com/document/d/1DzycCIAjIUONikpp109OzexD4qOR0oyY4zKc4WJju6U/edit?usp=sharing
に記載してあります。(長すぎたため質問に収まらず)