日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

selenium打开Firefox、IE、Chrome浏览器【python】

發(fā)布時(shí)間:2025/3/15 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 selenium打开Firefox、IE、Chrome浏览器【python】 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

selenium打開(kāi)不同瀏覽器的腳本。

1.Firefox

from selenium import webdriver
driver=webdriver.Firefox()

driver.get("http://www.baidu.com")

'''

這里要注意打開(kāi)的域名一定要加前http://

否則會(huì)報(bào)錯(cuò):selenium.common.exceptions.WebDriverException: Message: unknown error: unhandled inspector error: {"code":-32603,"message":"Cannot navigate to invalid URL"}

'''

2.IE和Chrome

from selenium import webdriver
chromedriverpath="C:\Program Files (x86)\Google\Chrome\Application\chromedriver"
'''

selenium打開(kāi)IE和Chrome需要有瀏覽器驅(qū)動(dòng),需要額外下載的,chromedriverpath是驅(qū)動(dòng)路徑,在下面的的函數(shù)里面當(dāng)參數(shù)傳入。

如果想firefox直接調(diào)用會(huì)報(bào)錯(cuò):selenium.common.exceptions.WebDriverException: Message: 'chromedriver1' executable needs to be in PATH.

'''

driver=webdriver.Chrome(chromedriverpath)
driver.get("http://www.baidu.com")

?

轉(zhuǎn)載于:https://www.cnblogs.com/bbwc/p/5404662.html

總結(jié)

以上是生活随笔為你收集整理的selenium打开Firefox、IE、Chrome浏览器【python】的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。