import requests
from lxml import html

USERNAME = "07465253874"
PASSWORD = "eq*mP@qCkxT6f$5C"

LOGIN_URL = "https://www.three.co.uk/My3Account/Login"
URL = "https://www.three.co.uk/New_My3/Account_balance?id=My3_CheckYourBalanceLink"

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": USERNAME, 
        "password": PASSWORD, 
        "csrfmiddlewaretoken": authenticity_token
    }

    # 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()
@@ -1,12 +1,23 @@
+%22%22%22The%0A%22%22%22%0A
 import reque
@@ -212,36 +212,8 @@
 ance
-?id=My3_CheckYourBalanceLink
 %22%0A%0Ad
@@ -222,16 +222,30 @@
  main():
+%0A    %22%22%22The%22%22%22
 %0A    ses
@@ -509,25 +509,16 @@
 load = %7B
-%0A        
 %22usernam
@@ -531,25 +531,16 @@
 ERNAME, 
-%0A        
 %22passwor
@@ -557,37 +557,11 @@
 RD, 
-%0A        %22csrfmiddlewaretoken
+%22lt
 %22: a
@@ -581,35 +581,14 @@
 oken
-%0A    
 %7D%0A
-%0A
     
-# Perform login
 %0A   
@@ -688,25 +688,8 @@
 ))%0A%0A
-    # Scrape url%0A
     
@@ -801,106 +801,8 @@
 nt)%0A
-    bucket_names = tree.xpath(%22//div%5B@class='repo-list--repo'%5D/a/text()%22)%0A%0A    print(bucket_names)
 %0A%0Aif

Update mobile_broadband_credit