Last active
August 29, 2015 14:15
-
-
Save srgrn/0ca2bc79a46c381a35d1 to your computer and use it in GitHub Desktop.
create a team in hockeyapp using python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import requests | |
import os | |
import cookielib | |
from lxml import html | |
EMAIL = "USEREMAIL" | |
PASSWORD = "PASSWORD" | |
URL = "https://rink.hockeyapp.net/users/sign_in" | |
# Start a session so we can have persistant cookies | |
def test(): | |
session = requests.session() | |
# This is the form data that the page sends when logging in | |
login_data = { | |
'user[email]': EMAIL, | |
'user[password]': PASSWORD, | |
'submit': 'commit', | |
} | |
# Authenticate | |
r = session.post(URL, data=login_data) | |
team_data = { | |
'team[name]' : "test2", | |
'team[owner_id]' : "USERID", | |
'commit': 'Save', | |
'invite': "all", | |
'message': 'Welcome', | |
'members[]': ["<ADDRESS>|email|3", "<OTHERADDRESS>|email|3"], | |
'submit': 'commit', | |
} | |
new_team = session.get("https://rink.hockeyapp.net/manage/teams/new") | |
tree = html.fromstring(new_team.text) | |
meta = tree.xpath('//meta') | |
team_data[(meta[1].items())[0][1]] = (meta[2].items())[0][1] | |
resp = session.post('https://rink.hockeyapp.net/manage/teams', data=team_data) | |
return resp | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment