Python用モジュール「Selenium」で指定した要素をクリックする方法についてソースコード付きでまとめました。
指定した要素をクリック
Python用モジュール「Selenium」を用いて、指定した要素をクリックできます。
サンプルコード(Python3)
サンプルプログラムのソースコードです。
# -*- coding:utf-8 -*- from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options URL = 'https:/hogehoge' ID_NAME = 'menu-item-10797' # Chromeで操作する場合 driver = webdriver.Chrome() driver = webdriver.Chrome(executable_path='chromedriver') # ページをロード driver.get(URL) # ID名:custom_html-2 の要素を取得 tag_id = driver.find_element_by_id(ID_NAME) tag_id.click()

【Python】Seleniumの使い方(ブラウザ自動操作)
Python用モジュール「Selenium」でブラウザを操作する方法についてソースコード付きでまとめました。

【Python超入門】使い方とサンプル集
Pythonの使い方について、基礎文法から応用例まで入門者向けに解説します。
コメント