Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
172 views
in Technique[技术] by (71.8m points)

python - Using webbrowser instead of Selenium

I am trying to make an auto yt searcher and this is as far as I got. I don't really understand on how to user selenium so I am using web-browser what's currently not happening is it is not opening or searching on the search bar (I used the XPath)or does anyone know a tutorial for selenium

import webbrowser
import time


url = 'http://youtube.com'

chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'

webbrowser.get(chrome_path).open(url)

LastName = "nice"

time.sleep(2)

last = webbrowser.open('//*[@id="search"]')

webbrowser.get(LastName)
question from:https://stackoverflow.com/questions/65916287/using-webbrowser-instead-of-selenium

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can't use the actual Google Chrome Browser.

Instead you have to use ChromeDriver that works the same as the standard Chrome but you can use it with selenium.

You can download it here.

Once installed specify the correct path of chromedriver.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...