data analysis & visualization

크롬 설치하기

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()