Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【Python】CentOS上でFireFoxを起動してSeleniumを利用する方法
from pyvirtualdisplay import Display
from selenium import webdriver
# 仮想ディスプレイ起動
display = Display(visible=0, size=(1024, 768))
display.start()
# FireFox起動
browser = webdriver.Firefox()
browser.get('http://www.yahoo.co.jp/')
print browser.page_source
# FireFoxを閉じる
browser.close()
# 仮想ディスプレイを終了
display.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment