データを自動送信するには
htmlからidを自動取得
BeautifulSoupとrequest 2つ使う
インスト方法
インスト
pip install beautifulsoup4
pip install lxml
動作確認
sample.py
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
# WebDriverの設定(Chromeを使用)
driver = webdriver.Chrome()
# 応募ページを開く
url = "https://example.com/apply" # ここを実際のURLに変更
driver.get(url)
# ページの読み込み待機
time.sleep(3)
try:
# 応募ボタンを探す(buttonタグ or input[type="submit"] など)
apply_button = driver.find_element(By.XPATH, "//button[contains(text(),'応募') or contains(text(),'Apply')]")
# 応募ボタンをクリック
apply_button.click()
except Exception as e:
print("ボタンめよら:", e)
# 数秒待ってから閉じる
time.sleep(5)
driver.quit()