Basics of webscraping using selenium

Firstly,you have to install selenium from PythonPackageIndex using pip command.

Ran the bellow code but an exception has occured.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

# pyvirtualdisplayを用いる場合
from pyvirtualdisplay import Display
display = Display(visible=0, size=(1024, 768))
display.start()
driver = webdriver.Firefox()
WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

Seemed like there was not any ‘geckodriver’ in PATH..

In the first place,you must get geckodriver installed if you don’t have it.

you can download it following the instruction  in the page bellow.

http://d.hatena.ne.jp/rougeref/20161014

Then,run the code bellow after ‘mkdir’ for geckodriver executable file.

export PATH=$PATH:’/Users/yoshinobuhiroaki/Desktop/geckodriverdir’

Screenshot 2016-11-14 17.09.05.png

Now,you can get the result like above if you successfully finished.

[Reference]

http://qiita.com/hiroseabook/items/c161462844aef87e0f0d

http://qiita.com/yasunori/items/7463b3ab3191d2fbbf1d

Advertisements