LoginSignup
5
4

More than 3 years have passed since last update.

python selenium chromedriver beautifulsoup

Last updated at Posted at 2020-03-25

サンプルコード1 (シンプルに表示をするだけ)


import time
from selenium import webdriver
import chromedriver_binary

driver = webdriver.Chrome()

driver.get('https://xxx')
time.sleep(2)    # 2秒のウェイト

driver.close()
driver.quit()

サンプルコード2(headlessモード:表示をしない & beautifulsoupでパース)


from bs4 import BeautifulSoup

import time
from selenium import webdriver
import chromedriver_binary
from selenium.webdriver.chrome.options import Options

option = Options()
option.add_argument('--headless')
driver = webdriver.Chrome(options=option)

driver.get('https://xxx')
time.sleep(2)    # 2秒のウェイト

# パースする場合
soup = BeautifulSoup(driver.page_source,'html.parser')


driver.close()
driver.quit()

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4