使用selenium的时候导入key
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.key import Keys
显示ModuleNotFoundError: No module named 'selenium.webdriver.commom'
runfile('D:/anaconda/爬虫.py', wdir='D:/anaconda')
Traceback (most recent call last):
File D:\anaconda\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File d:\anaconda\爬虫.py:36
from selenium.webdriver.commom.keys import Keys
ModuleNotFoundError: No module named 'selenium.webdriver.commom'
删掉common后面的内容
from selenium import webdriver
from selenium.webdriver import By
from selenium.webdriver import Keys
显示
ImportError: cannot import name 'By' from 'selenium.webdriver' (D:\anaconda\Lib\site-packages\selenium\webdriver_init_.py)
runfile('D:/anaconda/爬虫.py', wdir='D:/anaconda')
Traceback (most recent call last):
File D:\anaconda\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File d:\anaconda\爬虫.py:35
from selenium.webdriver import By
ImportError: cannot import name 'By' from 'selenium.webdriver' (D:\anaconda\Lib\site-packages\selenium\webdriver\__init__.py)
最后把by行后面的内容保留,key行的commom后内容删除,可以正常运行
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver import Keys
这是为什么呢