Python+Selenium+Chromeのウェブスクレイピングで,ボタンクリックの操作を容易にするために,コードを実装します.
ボタンクリック
class名で取得しても,複数のボタンで同じクラス名が使用されているサイトもあるので,ボタンの文字列を指定してクリックするようなコードを実装しました.
python
def button_click(button_text):
buttons = driver.find_elements_by_tag_name("button")
for button in buttons:
if button.text == button_text:
button.click()
break
まとめ
Python+Selenium+Chromeのウェブスクレイピングで,ボタンクリックの操作を容易にするために,コードを実装しました.