标签:elf 并且 有一个 art 使用方法 ring os.path 方法 col
一、用selenium模块控制浏览器
selenium能让用户通过Python直接控制浏览器,实际点击链接,填写登录信息,几乎就像一个人类与浏览器交互。这能比使用Request和Beautiful Soup模块完成更多的事情,能让你以更高级的方式和浏览器交互,但是也有一个确定,比如当你只是想下载一个文件时,前者就有些复杂,并且难以在后台运行
1.1启动selenium控制的浏览器
以form selenium import webdriver来导入webderiver模块
遇到了问题:
1)selenium.common.exceptions.WebDriverException:
在执行以下代码时出现了上个异常
>>> from selenium import webdriver
>>> browser=webdriver.Firefox()
Traceback (most recent call last):
File "C:\Users\Administrator.SC-201605202132\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\Administrator.SC-201605202132\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\Administrator.SC-201605202132\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
browser=webdriver.Firefox()
File "C:\Users\Administrator.SC-201605202132\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "C:\Users\Administrator.SC-201605202132\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: ‘geckodriver‘ executable needs to be in PATH.
解决办法:
错误是英文的,我先把他翻译过来之后,由于是第一次使用selenium模块,我搜索了模块的使用方法,然后发现需要webdriver驱动文件,
六、项目
标签:elf 并且 有一个 art 使用方法 ring os.path 方法 col
原文地址:https://www.cnblogs.com/Gaoqiking/p/10499996.html