環境は整った?
from selenium import webdriver
driver = webdriver.Chrome()
driger.implisitly_wait(3)
driver.get('https://www.library.chiyoda.tokyo.jp/')
schedule_el = driver.find_elements_by_class_name('schedule-list01__text')
print([s.text for s in schedule_el])
かと思ったので上記のコードをjupyterlabで動かしてみた。
ModuleNotFoundError: No module named 'selenium'
あちゃ。
selenium入れなきゃダメじゃん。
!pip install selenium
としたら以下のエラーメッセージ
ERROR: Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
なかなかやるな。
ここでエラーメッセージコピペでgoogle先生に登場してもらう。
先生!お願いします。
ウム。
!pip install label-studio
ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
せ、せんせい!
!pip install label-studio --ignore-installed certifi
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tables 3.5.1 requires mock>=2.0, which is not installed.
astroid 2.2.5 requires typed-ast>=1.3.0; implementation_name == "cpython", which is not installed.
!pip check
tables 3.5.1 requires mock, which is not installed.
spyder 3.3.3 requires pyqt5, which is not installed.
astroid 2.2.5 requires typed-ast, which is not installed.
ちゅーわけで、それぞれインストール
!pip install mock
Successfully installed mock-5.0.1
!pip install pyqt5
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
spyder 3.3.3 requires pyqt5<=5.12; python_version >= "3", but you have pyqt5 5.15.9 which is incompatible.
またエラーでやんす。
!pip install --upgrade --user pyqt5==5.12
Successfully installed PyQt5_sip-4.19.19 pyqt5-5.12
!pip install typed-ast
Successfully installed typed-ast-1.5.4
んで、もう一回
!pip install label-studio --ignore-installed certifi
!pip install label-studio
!pip install selenium
これでエラーは排除できたっぽい。
また一番上のコードを実行すると…
WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127
きたーーー!127
chromedriverがみつからないってやつ。
原因は
chromedriverのパスが通ってない。
chromedriverのバージョンがブラウザのバージョンと違っている。
あたりらしいです。それでもエラー出るなら
前々回に書いたライブラリのインストール。
これで行こう。
ということで、また。