Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from lxml import html
- LOGIN_URL = "https://cas.sfu.ca/cas/login?service=https://my.sfu.ca/mysfu/auth&app=mySFU"
- URL = "https://my.sfu.ca/mysfu/"
- def main():
- session_requests = requests.session()
- # Get login csrf token
- result = session_requests.get(LOGIN_URL)
- tree = html.fromstring(result.text)
- authenticity_token = list(set(tree.xpath("//input[@name='lt']/@value")))[0]
- # Create payload
- payload = {
- "username": "v*****",
- "password": "Y*****",
- "lt": "LT-447-A4KGjbl5jVX4ZvRwNGRIL0xodSHcJY"
- }
- # Perform login
- result = session_requests.post(LOGIN_URL, data = payload, headers = dict(referer = LOGIN_URL))
- # Scrape url
- result = session_requests.get(URL, headers = dict(referer = URL))
- tree = html.fromstring(result.content)
- bucket_names = tree.xpath("//div[@class='repo-list--repo']/a/text()")
- print(bucket_names)
- if __name__ == '__main__':
- main()
- ####################################################################
- Username:
- <input id="username" name="username" tabindex="1" class="text" onfocus="GaveFocus(this)" type="text" value="" autocomplete="false"/>
- Password:
- <input id="password" name="password" tabindex="2" onkeypress="capLock(event)" class="text" onfocus="GaveFocus(this)" type="password" value="" autocomplete="off"/>
- Token:
- <input type="hidden" name="lt" value="LT-293557-0lx4PsiambnCMcpbaDLpbwzPxVEFh4" />
- Login URL
- https://cas.sfu.ca/cas/login?service=https://my.sfu.ca/mysfu/auth&app=mySFU
- Desired URL
- https://my.sfu.ca/mysfu/
- Fields submitted to
- /cas/login;jsessionid=003D1C4D4DC4F4D4E65AEB270D897C94.cas-ap2?service=https://my.sfu.ca/mysfu/auth&app=mySFU
- Logins managed by
- http://www.ja-sig.org/cas/
- ############################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement