初めてPythonでWebスクレイピングする時に役立ったサイト

バイト先で、Excelデータを作成する時に、いちいち検索して、クリックしてWebページ表示してコピペして…が面倒くさい!
じゃ、Webスクレイピングとかいうもので(詳しくは知らなかった)一気に引っ張ってくればいいのでは、と思ったがやり方がわからない。
コピペで取り敢えず動かしてみたのでその時に役に立ったサイトをメモ。


www.s-arcana.co.jp
単にどんなもんか試してみるにはこのサイトが一番シンプルだった。
ただ、コピペするだけだと以下のようなエラーが出てしまった。

$ python3 main.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1540, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'phantomjs'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 11, in <module>
    driver = webdriver.PhantomJS()
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 52, in __init__
    self.service.start()
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 71, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH. 

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.phantomjs.service.Service object at 0x10bbf8be0>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 163, in __del__
    self.stop()
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 135, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'

ということでphantomjsとやらをインストールするために以下のサイトを参考にさせて頂きました。
nigohiroki.hatenablog.com






はぁ…。

こんなことしてていいのか…修論進めなくちゃ…。。。。

無事修了出来るといいな…。