Selenium 크롤링

페이지 정보

작성자 조희승 댓글 0건 조회 7,728회 작성일 19-07-11 20:15

본문

https://beomi.github.io/2017/02/27/HowToMakeWebCrawler-With-Selenium/

https://blog.testproject.io/2018/02/20/chrome-headless-selenium-python-linux-servers/

https://snowdeer.github.io/linux/2018/02/02/ubuntu-16p04-install-chrome/




apt install python3-selenium

아래방법대로 크롬 설치 필요
$ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
$ sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
$ sudo apt-get update
$ sudo apt-get install google-chrome-stable





test.py
-------------------------------------------
#!/usr/bin/python3

from selenium import webdriver
from bs4 import BeautifulSoup


chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox') # required when running as root user. otherwise you would get no sandbox errors.
#driver = webdriver.Chrome(driver_path='/root/project/newsc/chromedriver', chrome_options=chrome_options, service_args=['--verbose', '--log-path=/tmp/chromedriver.log'])
driver = webdriver.Chrome(chrome_options=chrome_options, service_args=['--verbose', '--log-path=/tmp/chromedriver.log'])



#driver = webdriver.Chrome('/root/project/newsc/chromedriver')
driver.get('http://cslab.jbnu.ac.kr')
print(driver.title)

----------------------------------------------





apt install python3-bs4

댓글목록

등록된 댓글이 없습니다.