LoginSignup
2
3

More than 5 years have passed since last update.

Python で requests を使って Slack にログインする

Last updated at Posted at 2016-12-17

使用するモジュール

全体のコード

from bs4 import BeautifulSoup
import requests
import re

TEAM_NAME = "hoge"

payload = {
    'signin': "1",
    'email': 'email',
    'password': 'password'
}

login_url = 'https://%s.slack.com/' % TEAM_NAME

# ログインページにアクセス
session = requests.Session()
response = session.get(login_url)

# crumb の取得
bs = BeautifulSoup(response.text)
auth_token = bs.find(attrs={'name': 'crumb'}).get('value')
payload['crumb'] = auth_token

# ログインする
session.post(login_url, data=payload)
2
3
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
2
3