# 서버에서 selenium 사용 예제
# 가상의 디스플레이를 만들어 그 안에서 브라우져를 띄워서 실행
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Chrome(executable_path='/usr/lib/chromium-browser/chromedriver')
browser.get("http://www.google.com")
print(browser.title)
browser.quit()
display.stop()
sudo apt-get install build-essential chrpath libssl-dev libxft-dev libfreetype6-dev libfreetype6 libfontconfig1-dev libfontconfig1 -y
sudo wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
sudo tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/
sudo ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/
# 서버에서 selenium 사용 예제
# 가상의 디스플레이를 만들어 그 안에서 브라우져를 띄워서 실행
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.PhantomJS(executable_path='/usr/local/bin/phantomjs')
browser.get("http://www.google.com")
print(browser.title)
browser.quit()
display.stop()
In [1]: from notebook.auth import passwd In [2]: passwd() Enter password: Verify password: Out[2]: 'sha1:f24baff49ac5:863dd2ae747212ede58125302d227f0ca7b12bb3' In [3]: exit # Copy 'sha~~~' & Paste to jupyter_notebook_config.py (c.NotebookApp.password) # Enter password 에서 넣은 암호를 나중에 웹에서 접속할 때 처음에 넣어주어야 합니다.
c = get_config() c.NotebookApp.password = u'sha1:9506af11c688:9b5b486a01114bd3e38e52fdc2ea7f4c183f9a1e' c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False c.NotebookApp.port_retries = 8888 c.NotebookApp.notebook_dir = u'/home/ubuntu/DataScience'