Help us understand the problem. What is going on with this article?

[selenium] Pythonで動かすまで

More than 1 year has passed since last update.

パッケージインストール

$ pip install selenium

ブラウザのドライバをインストール

ドライバをDLしてきて、/usr/local/bin におく。

サンプルコード

#-*- coding: utf-8 -*-                                                                                                                                                                                                                                                          

from selenium import webdriver

def main():
    """                                                                                                                                                                                                                                                                         
    """
    driver = webdriver.Chrome()
    driver.get('https://www.google.co.jp/')
    driver.find_element_by_name('q').send_keys("How to Become a Hacker")
    driver.find_element_by_name('f').submit()
    driver.close()                                                                                                                                                                                                                                                             

    driver = webdriver.Firefox()
    driver.get('https://www.google.co.jp/')
    driver.find_element_by_name('q').send_keys("How to Become a Hacker")
    driver.find_element_by_name('f').submit()
    driver.close()                                                                                                                                                                                                                                                             

if __name__ == '__main__':
    """ entry point                                                                                                                                                                                                                                                             
    """
    main()
ponsuke
麻布十番で働くシステムエンジニア/エンジニアチームマネージャ
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away