1.selenium安装:
pip install -U selenium参考:https://pypi.python.org/pypi/selenium#downloads2.下载firefox驱动:https://github.com/mozilla/geckodriver/releases3.把geckodriver.exe所在目录配置到path环境变量4.一个简单示例:
1 from selenium import webdriver 2 3 driver=webdriver.Firefox() 4 5 driver.get("http://www.sogou.com") #程序运行结束会自动打开火狐浏览器并打开搜狗网页
1 from selenium import webdriver 2 3 driver=webdriver.Firefox() 4 5 driver.get("http://www.sogou.com") 6 print(driver.title) 7 8 driver.get("http://www.suning.com") #http://不能省否则会报错 9 print(driver.title) 10 driver.quit() #此语句的作用是关闭黑窗口和浏览器
时间: 2024-10-12 01:35:47