help with selenium - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: help with selenium (/thread-31751.html) |
help with selenium - ZinkQ - Jan-01-2021 why it doesnt work? my code: from selenium import webdriver driver = webdriver.Chrome() driver.get("http://www.google.com")error:
RE: help with selenium - snippsat - Jan-01-2021 (Jan-01-2021, 03:41 PM)ZinkQ Wrote: Message: unknown error: cannot find Chrome binaryYou most download Chrome webdriver. So chromedriver.exe most be in Windows path or same folder as you run script from.Working example,most also push the accept button before can search. from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys import time #--| Setup options = Options() #options.add_argument("--headless") options.add_argument('--log-level=3') browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options) #--| Parse or automation browser.get("http://www.google.com") time.sleep(2) browser.switch_to.frame(0) accept_button = browser.find_elements_by_css_selector('#introAgreeButton')[0] accept_button.submit() time.sleep(2) search_bar = browser.find_elements_by_css_selector('div.a4bIc > input')[0] search_bar.send_keys('2021') search_bar.submit() RE: help with selenium - robsuttonjr - Jan-04-2021 As far as the path to the driver, there are slight differences in get it to work on Windows and Linux. Linux: DRIVER_PATH = '/usr/bin/chromedriver' driver = webdriver.Chrome(options = options, executable_path=DRIVER_PATH) Windows: DRIVER_PATH = 'C:\webscrape\chromedriver\chromedriver_86.exe' driver = webdriver.Chrome(options = options, executable_path=DRIVER_PATH) *Note that there are other differences in getting web scrape scripts to work on Windows and Linux. In other words a script that works fine on Windows likely will not work but just copying and pasting to Linux. Not just the pathing but other things are different. Also there are different versions of chromedriver. |