파이썬 Selenium linux 환경 구축하기 (ubuntu)
크롬 설치하기
https://linuxize.com/post/how-to-install-google-chrome-web-browser-on-ubuntu-18-04/
크롬 버전 체크하기
google-chrome --version
크롬드라이버 설치하기
wget -N http://chromedriver.storage.googleapis.com/해당버전/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
chmod +x chromedriver
sudo mv -f chromedriver /usr/local/share/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
python 실행 후 테스트하기
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from time import sleep
# create a new chrome session
options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome(chrome_options=options, executable_path="/home/ducj/crawling/chromedriver")
driver.implicitly_wait(3)
driver.maximize_window()
# Navigate to the application home page
driver.get("http://www.google.com")
driver.get("https://www.google.co.kr/maps")
sleep(0.05)
search=driver.find_element_by_css_selector('input#searchboxinput.tactile-searchbox-input')
search.clear()
search.send_keys('대구대')
search.send_keys(Keys.ENTER)
driver.current_url
driver.close()
'ubuntu' 카테고리의 다른 글
라즈베리파이 openCV 설치 및 관절 인식 (2) | 2020.02.13 |
---|---|
jupyter-notebook에서 matplotlib 한글폰트 설정 (0) | 2020.02.13 |
우분투 팀뷰어 끊김 현상 (0) | 2019.03.26 |
주피터 서버 만들기(최종) (0) | 2019.03.25 |
NAS 설치(삼바, mysql) (0) | 2019.03.15 |