1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

自動化ソフトを作ってみる #Qiitaログインの自動化

Last updated at Posted at 2025-08-03

こんにちは。らむねです。

Qiitaを今後使っていこうと思い、簡単な自動化ソフトでも作ってみようと思いいたりました。

作成の背景

本成果物は、PCを開いたとき、Qiitaに勝手にログインしてくれるようにします。

※PythonとSelenium(Selenium Webdriver)でつくるのがおすすめだとClaudeに言われたので、その通り作っていきました。

成果物概要

PCを起動したとき、Qiitaに勝手にログインしてくれるようにします。

別途batファイルを作っておき、起動時に自動でログイン状態を保持してくれるようにしました。(ログイン後、そのタブは削除されます)

コードは以下です

qiita.py

# seleniumの基本的な更新
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

#Chromeドライバマネジャーの更新
service = Service(ChromeDriverManager().install)
driver = webdriver.Chrome(service=service)

#新たにChromeのWEBサイトにアクセスする
driver =webdriver.Chrome()
driver.get("https://qiita.com/login?callback_action=login_or_signup&redirect_to=%2F&realm=qiita")

#ユーザー名とパスワードの欄を探す
identity = driver.find_element(By.ID, "identity")
password = driver.find_element(By.ID, "password")

#ユーザー名、パスワードを入力 (※your_username,your_passwordは、ご自身のユーザー名とパスワードに書き換えてください)
identity.send_keys("your_username")
password.send_keys("your_password")

#ログインする 
login_button = driver.find_element(By.XPATH, "//input[@type='submit']")
login_button.click()

コードの備考

・identityとしたのは、Qiitaのログインページを「左クリック→検証」すると、type=identityと記載されていたためです。

学んだこと

学んだことを以下にまとめます。

  1. Seleniumとは
    | Webアプリのテスト自動化のための操作自動化に使うオープンソースフレームワーク。

※種類としては、Selenium IDE(統合開発環境)、Selenium Grid、Selenium Webdriverなどがある。
参考サイト:https://qiita.com/Chanmoro/items/9a3c86bb465c1cce738a

2.ドライブマネジャーはバージョンによって異なる

3.パスワード欄などは、左クリック→検証することで、事前に確認する必要がある

4.batファイル(バッチファイル)を使うと、Windowsでの自動操作が可能になる

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?